0

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 ?

Community
  • 1
  • 1
Thalia
  • 13,637
  • 22
  • 96
  • 190

1 Answers1

1

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.

Kuba hasn't forgotten Monica
  • 95,931
  • 16
  • 151
  • 313
  • I think I understand this better - so if I wanted to check for "debug" with the same command I would say "CONFIG(release,debug|debug)" ? – Thalia Sep 24 '14 at 17:18
  • @Thalia No. You'd say `CONFIG(debug,release|debug)`. It makes no sense to say `debug|debug`, since that's an alternative of equals and reduces to `debug`. The first argument to `CONFIG` is what you're checking for. The second argument is what `CONFIG` entries to check in - the latest of *either* of those entries is compared to the first argument and the result of the comparison is returned. – Kuba hasn't forgotten Monica Sep 24 '14 at 17:21
  • Thank you very much, for the answer and the additional explanation and edit – Thalia Sep 24 '14 at 17:34