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?

Recommended Answers

All 4 Replies

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

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. 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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.