使用该行使用 g++(来自使用 qmake 生成的 Makefile)进行编译
#if !QT_CONFIG(printer)
// do something
#endif
在 g++ (7.3.0) 上给出预处理器错误
test.cpp:25:6: error: division by zero in #if
#if !QT_CONFIG(printer)
和铿锵声(6.00)
test.cpp:25:6: error: division by zero in preprocessor expression
#if !QT_CONFIG(printer)
^~~~~~~~~~~~~~~~~~
/usr/include/x86_64-linux-gnu/qt5/QtCore/qglobal.h:84:30: note: expanded from macro 'QT_CONFIG'
#define QT_CONFIG(feature) (1/QT_FEATURE_##feature == 1)
~^~~~~~~~~~~~~~~~~~~~~
1 error generated.
其中 clang++ 给出了更详细的输出。printer
未启用,因此建议使用宏进行条件编译。QT 版本是 5.9.5。任何建议(错误用法?)表示赞赏。