问题描述
我在我的Qt项目中使用GCC -Weffc ++
选项。为了抑制来自Qt头文件的警告,我添加了 QMAKE_CXXFLAGS + = -isystem $(QTDIR)\include
。
但是这并没有抑制所有的警告,因为 $(QTDIR)\include\QtCore\quuid.h
$ b $,所以我仍然从 QUuid 类中感到恼人的警告b文件包含
.. \\\\rc \corelib\plugin\quuid.h
。
我尝试添加
QMAKE_CXXFLAGS + = - 系统$(QTDIR)\ src
和
QMAKE_CXXFLAGS + = - 系统$(QTDIR)\src\corelib\plugin
但它没有帮助。有没有办法解决这个问题?
I use GCC -Weffc++
option in my Qt project. To suppress warnings from Qt headers i add QMAKE_CXXFLAGS += -isystem $(QTDIR)\include
.
But this doesn't suppress all warnings, i still get annoying warnings from QUuid class because $(QTDIR)\include\QtCore\quuid.h
file includes..\..\src\corelib\plugin\quuid.h
.
I tried to addQMAKE_CXXFLAGS += -isystem $(QTDIR)\src
andQMAKE_CXXFLAGS += -isystem $(QTDIR)\src\corelib\plugin
but it didn't help. Is there a way to fix this?
推荐答案
您需要单独禁用每个目录。示例来自我的项目:
You need to suppress each directory separately. Example from my project:
QMAKE_CXXFLAGS += -isystem "$$[QT_INSTALL_HEADERS]/qt5" -isystem "$$[QT_INSTALL_HEADERS]/qt5/QtWidgets" \
-isystem "$$[QT_INSTALL_HEADERS]/QtXml" -isystem "/usr/include/qt5/QtGui" \
-isystem "$$[QT_INSTALL_HEADERS]/QtCore"
或者,为了自动执行上述操作,您已经启用了精确的Qt模块:
Or, to automate the above for the exact Qt modules you have enabled:
for (inc, QT) {
QMAKE_CXXFLAGS += -isystem \"$$[QT_INSTALL_HEADERS]/Qt$$system("echo $$inc | sed 's/.*/\u&/'")\"
}
# Still need this separately:
QMAKE_CXXFLAGS += -isystem "$$[QT_INSTALL_HEADERS]/qt5"
这篇关于如何抑制包含在标题中的文件的警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!