How to suppress warnings for file included from header

前端 未结 1 881
梦谈多话
梦谈多话 2020-12-19 09:56

I use GCC -Weffc++ option in my Qt project. To suppress warnings from Qt headers i add QMAKE_CXXFLAGS += -isystem $(QTDIR)\\include.
But this

1条回答
  •  天命终不由人
    2020-12-19 10:21

    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"
    

    0 讨论(0)
提交回复
热议问题