In C, how do I restrict the scope of a global variable to the file in which it's declared?

后端 未结 4 1890
灰色年华
灰色年华 2020-12-18 01:52

I\'m new to C. I have a book in front of me that explains C\'s \"file scope\", including sample code. But the code only declares and initializes a file scoped variable - it

4条回答
  •  爱一瞬间的悲伤
    2020-12-18 02:35

    Remove the second include instruction. As it was said above...

    Before compiling your code a compiler preprocesses it. In that stage it processes all the instructions starting with '#', like #include, #define and etc.

    To see the result of that stage you can just run 'gcc -E ' (if you are using gcc).

提交回复
热议问题