Does Qt offer a (guaranteed) debug definition?

Samuel Harmer picture Samuel Harmer · Jan 10, 2012 · Viewed 23.6k times · Source

Does anyone know an officially supported way to include debug-build only code in Qt? For example:

#ifdef QT_DEBUG
// do something
#endif

Basically like Q_ASSERT but for more complex tests.

I can't seem to find any documentation which says that the Qt framework guarantees to define a debug macro. If there isn't, what would be a sensible unofficial way to implement this feature project wide?

Answer

laalto picture laalto · Jan 10, 2012

Qt defines QT_NO_DEBUG for release builds. Otherwise QT_DEBUG is defined.

Of course you are free to specify any DEFINES in your .pro files and scope them for either debug or release.