Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 426
sashoalm Avatar asked Feb 21 '13 09:02

sashoalm


1 Answers

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.

like image 101
Michael Wild Avatar answered Sep 19 '22 21:09

Michael Wild