C++ #define preprocessor

cc-preprocessorvisual studio

I need to know that does the #define directive in C++ declares global label? By global I mean visible in every file?

I'm using Visual Studio 2008, (guess if that matters)

Best Answer

No, only in the current translation unit.

I.e. every file which has #define, or includes a file that has the #define will see the definition.

Edit, to respond to your comment: to get a define in every file, either put it in a header which gets included everywhere, or use some compiler option to get defines added.

e.g. for gcc one would do

gcc -Dthedefine=itsvalue

Not sure how one specifies such includes in VC++, but I'm sure it's possible somehow.