# VC++ 2010 preprocessor directives don't seem to be updating

This topic is 1848 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have this at the top of my main.cpp:

#define EG_DEBUG_MODE 1


I have this as part of a separate file log.cpp (within two namespaces):

/* log_iostream */
void log_iostream(std::string message)
{
// only log to iostream in debug mode
#ifndef EG_DEBUG_MODE
return;
#endif

std::cout << message << std::endl;
}


Now regardless of if I comment out or delete the #define in main.cpp, the return still gets compiled.

I've tried rebuilding instead of just a normal build but this still yielded the same results. I also thought the problem might be with which files are compiled first but the according to the build output console main.cpp is being compiled first, followed by log.cpp.

I tried defining EG_DEBUG_MODE through Visual Studio's project properties menu and this cleared up the issue, but I really would like to be able to make it work just through the code.

Some other info that may help is that I have this a few lines under the definition in main.cpp:

#ifndef EG_DEBUG_MODE
#endif


This line works as expected.

I'm not sure if i'm being retarded or if something's wrong with Visual Studio

##### Share on other sites
You're being retarded. :P

Remember that each cpp file (translation unit) is compiled separately from the rest. Therefore, only EG_DEBUG_MODE will be defined for main.cpp. You'll need to define EG_DEBUG_MODE in each cpp file, or add it to your project's preprocessor settings.

##### Share on other sites

Gah I knew I was missing something -.-

Thanks for helping me :p

• 38
• 12
• 10
• 10
• 9
• ### Forum Statistics

• Total Topics
631365
• Total Posts
2999581
×