In Visual Studio (C++ Express 2008) I can set pre-processor definitions by going to:
Project Settings - C/C++ - Preprocessor
and add them to Preprocessor definitions which I can then use in #ifdef statements in my code. This is useful to seperate out code for debug and release builds.
I.e.
#ifdef MY_BUILD_DEBUG
#else
#endif
I'm struggling how to do this in QtCreator. I've tried putting the preprocessor definitions in:
Projects - Build Steps - QMake - Details - Additional Arguments
but they never get picked up in the #ifdef.
I've also tried doing this in the project .pro file which also doesn't work for me:
CONFIG(debug, debug|release){
message("debug, debug|release")
DEFINES += MY_BUILD_DEBUG
}
CONFIG(release, debug|release){
message("release, debug|release")
DEFINES += MY_BUILD_RELEASE
}
The strange thing here is that in the release build, the debugging output is 'debug, debug|release' only but the MY_BUILD_RELEASE definition is there since it picks it up in the #ifdef.
It's as if the DEFINES are added regardless of the build configuration, which is what I thought the CONFIG and braces was for.
Any ideas?