Qt Creator's intellisense grays out #ifdef _DEBUG blocks even though Debug build is selected

c++, conditional-compilation, qt, qt-creator

Solution

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.

Problem

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.

Original source

Related problems