In QT, how to distinguish between debugging and release of a preprocessor

I know that we can use #if DEBUG #else #endif in C #, so I think Qt has the same way to do this, for example:

QString Paths::sqlScriptPath()
{
#if DEBUG
    return "D:\edocclient\edocclient-build-Desktop_Qt_4_8_4_QT4_8_4-Debug\sql";
#else
    return "D:\edocclient\edocclient-build-Desktop_Qt_4_8_4_QT4_8_4-Release\sql";
}

but it didn’t work.

+5
source share
1 answer

The correct Qt macros for this are QT_DEBUG. Thus, the code will look like this:

QString Paths::sqlScriptPath()
{
#ifdef QT_DEBUG
    return "D:\edocclient\edocclient-build-Desktop_Qt_4_8_4_QT4_8_4-Debug\sql";
#else
    return "D:\edocclient\edocclient-build-Desktop_Qt_4_8_4_QT4_8_4-Release\sql";
#endif
}
+4
source

All Articles