c++macosqtclang

How can I stop warnings about unused private fields?


While compiling a collection of files in a Qt project, I'm seeing lots of warnings similar to this one.

In file included from /usr/local/Trolltech/Qt-4.8.6/include/QtGui/qevent.h:52:
/usr/local/Trolltech/Qt-4.8.6/include/QtGui/qmime.h:119:10: warning: private field 'type' is not used [-Wunused-private-field]
    char type;
     ^

Per suggestions from various searches, I did add the entry

QMAKE_CXXFLAGS += -Wno-unused-private-field

to the .pro file and confirmed that it shows up properly in compiler invocations but I'm still getting that warning.

I'm running Qt on a Mac with clang.

Thanks in advance for any insights.


Solution

  • Per this answer, try

    QMAKE_CXXFLAGS_WARN_ON += -Wno-unused-private-field
    

    It appears that the QMAKE_CXXFLAGS_WARN_ON flags are added to the compiler command line after QMAKE_CXXFLAGS, and would re-enable that warning (because QMAKE_CXXFLAGS contains -Wall).