When I have in my code an #ifdef
like this
#ifdef _DEBUG
printf("This is a debug build");
#endif
Qt Creator grays out the printf
even though it is a debug build, and when I run it "This is a debug build"
gets printed.
It seems that the intellisense isn't seeing the preprocessor defines that will be passed to the compiler via the command line (i.e. -D_DEBUG
) instead of being defined in the header/source files.
The following works just fine in my *.pro
file:
CONFIG(debug, release|debug):DEFINES += _DEBUG
Switching the build type then also swaps the greyed-out area. I'm using Qt5, though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With