tags:

views:

26

answers:

2

Is there a way to determine the active configuration (that means Debug or Release) in code? Something along the lines of

#ifdef XCodeConfigurationDebug
    ...  
#endif  

#ifdef XCodeConfigurationRelease
    ...  
#endif  

I know that it's possible to do this by adding custom compiler flags. However, I'm looking for a more global solution.

+1  A: 

i figure it out using the preprocessor declarations. you can add your own definition, or NDEBUG is another common one to declare in release.

Justin
Yeah, that's correct, but I was looking for a way that doesn't involve fiddling with the build settings. I need this for some fragment of code that will be included in another XCode project, I don't know the build settings of which. But, thx anyway! :)
hennes
+1  A: 

There is the flag __OPTIMIZE__ that is defined when on RELEASE mode, and so:

#ifndef __OPTIMIZE__
// code for debug mode
#else
// code for release
#endif
vfn
Great, that works. Thx!
hennes