From Electron Cloud

Jump to: navigation, search

Stringify a define

If you would like to pass a string into a define via the compiler -D directive, but need to use it as if it was a quoted #define, it takes a pair of macros (verified to work on g++ and also Visual Studio):


then it can be used like this:

QFile uiFile(":" STRINGIFY(UI_FILE));

and in the .pro file if using Qt:

DEFINES += UI_FILE="some.ui"

so when it's compiled:

g++ foo.cpp -DUI_FILE=some.ui ...

(oh noes, it's DUI!)

Personal tools