How to add pre processing defs (macros) to qt creator?

Bharathwaaj picture Bharathwaaj · Sep 6, 2010 · Viewed 45k times · Source

In Eclipse there is an option to specify pre processing defines (#ifdef macros) to a project by using the Symbols option in Paths and Symbols. This helps in effective indexing of code which is cross platform. Is there any option to provide these in Qt creator?

Answer

Tobias Hunger picture Tobias Hunger · Sep 8, 2010

It depends:-)

The following is assuming you are using qmake based projects:

First you can add DEFINES += SOME_DEFINE=value into your .pro file. That is picked up inside creator and when building on the command line and should also show up when creating a MSVC or XCode project from the .pro file.

Then you can add DEFINES += SOME_DEFINE=value to the qmake call that Qt Creator will issue when configuring the project. That happens in the Project Mode, Build Settings, QMake Steps.

Finally, you can put #define SOME_DEFINE value liens into a header file and include that. That works for all kinds of projects:-)