Beforehand I know how to define a macro in a file like header file by using #define directive but I want to know, regarding Visual C++ compiler, is there any kind of file which is specifically used to hold a macro so that we can use it anywhere in our code we need by some directive which takes name of that file as input?

Are you talking about precompiled header files? Both Microsoft's VC++ 2010 (and earlier versions too) and g++ support that (other compilers might too, I don't know). You have to create a header file that includes other header files as well as function prototypes, constants, classes, structures and externs. Then you just have to include that header file in each of the *.cpp files. It makes compiling large projects a lot faster because the compiler will not process all those header files for each *.cpp file.

Edited 6 Years Ago by Ancient Dragon: n/a

No. Each unit has it's own #include. Only the project cpp has #includes of all units.

Irrelevant to what I meant.

Are you talking about precompiled header files? Both Microsoft's VC++ 2010 (and earlier versions too) and g++ support that (other compilers might too, I don't know). You have to create a header file that includes other header files as well as function prototypes, constants, classes, structures and externs. Then you just have to include that header file in each of the *.cpp files. It makes compiling large projects a lot faster because the compiler will not process all those header files for each *.cpp file.

No I didn't mean that at all.

This article has been dead for over six months. Start a new discussion instead.