Jump to content
  • Advertisement
Sign in to follow this  
Lith

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

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

If you intended to correct an error in the post then please contact us.

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
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
#endif

This line works as expected.

 

 

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

Share this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
Share on other sites

Gah I knew I was missing something -.-

 

Thanks for helping me :p

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!