I am trying to prevent showing certain error messages in Release (as stated in my question Errors showing in Qt application - how to not display them in Release).
I am working on an application in Qt... on Windows, Mac OS X and Linux.
For Windows checking for symbols is quite simple:
#if defined (Q_OS_WIN32) && !defined (NDEBUG)
But checking for NDEBUG on Linux, with the project built using qmake, the NDEBUG is not recognized...
So I could create a constant in the pro file:
unix:CONFIG(release):DEFINES += NO_RELEASE_ERRORS
This worked for both Linux and Windows. But when I tried on mac, switching between debug and release configurations both seemed to give me the defined constant...
I have installed Qt 4.8 on the MAC but its installation may not have debug symbols...
How can I find on MAC a DEBUG and RELEASE type of symbol that can trigger or not display of errors ?
TL;DR When testing for debug or release in CONFIG
, use the two parameter test function CONFIG(x,debug|release)
, where x
is either debug
or release
, depending on what you wish to test for.
The CONFIG(release)
test is wrong. You need CONFIG(release,debug|release)
. Remember that there are multiple debug
and release
entries in the CONFIG
variable (just print it out and see for yourself). It's only the last one that counts. That's why you should supply the second parameter to the CONFIG
test function - it'll act only on the last entry to match debug|release
, and if that entry isn't release
, the test fails.