main.cpp 是:
#include <iostream>
int main()
{
#ifdef CONDITION
std::cout << "built in debug mode" << std::endl;
#endif
return 0;
}
.pro 文件是:
SOURCES += main.cpp
debug:DEFINES += "CONDITION"
问题是发布和调试构建输出:
built in debug mode
我错过了什么?
You may also use the : operator to perform single line conditional assignments; for example:
win32:DEFINES += QT_DLL
编辑:
改变
debug:DEFINES += CONDITION
到
DEBUG:DEFINES += "CONDITION"
解决了这个问题。为什么会这样仍然是个谜,因为我有:
CONFIG+=debug
并且不是
CONFIG+=DEBUG
带有调试配置的 qmake 参数。
还在文档中他们使用小写字母:例如
macx:debug {
HEADERS += debugging.h
}
最佳答案
此论坛帖子 ( http://www.qtcentre.org/archive/index.php/t-6028.html) 建议您可能需要使用 qDebug
或简单地使用 !release
。这完全未经测试,但值得一试。
关于c++ - 我的 qmake 条件语句有什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17851536/