Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
C++
#ifdef MY_BUILD_DEBUG
// Load test images
#else
// Open file dialog and browse to image folder
#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?
Posted

1 solution

You may use the built in preprocessor: QT_DEBUG
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900