[SOLVED] How to suppress warnings for file included from header


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
I tried to add
QMAKE_CXXFLAGS += -isystem $(QTDIR)\src
QMAKE_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"

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:

Answered By – dismine

Answer Checked By – Marie Seifert (BugsFixing Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *