How to suppress warnings for file included from header

余生颓废 提交于 2019-12-18 06:06:32

问题


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 add
QMAKE_CXXFLAGS += -isystem $(QTDIR)\src
and
QMAKE_CXXFLAGS += -isystem $(QTDIR)\src\corelib\plugin
but it didn't help. Is there a way to fix this?


回答1:


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"

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"


来源:https://stackoverflow.com/questions/11663702/how-to-suppress-warnings-for-file-included-from-header

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!