Please nominate your Qt Champions for 2021! https://forum.qt.io/topic/132134/looking-for-the-2021-qt-champions
How to suppress -Wreorder warning
I am writing a Qt5 desktop application including the openni library (Linux platform, 32 bit) . When I build the project I have a lot of warnings (-Wno-unknown-pragmas, -Wreorder) and I would like to suppress them.
Adding "QMAKE_CXXFLAGS_WARN_ON += -Wno-unknown-pragmas" in the .pro file, allows to suppress this kind of warning. But I am not able to suppress the -Wreorder.
#pragma GCC diagnostic ignored "-Wformat"
Note that in general the use of pragmas is not recommended.
The use of #pragma does not work, because it seems that Qt automatically add -Wall as option to the compiler.
Remove the flag in your .pro, add :
@QMAKE_CXXFLAGS -= -Wall@
I added "QMAKE_CXXFLAGS_WARN_ON -= -Wall" and of course it worked. But I don't want to disable all the warnings.
You can suppress all warning, and add only the warnings you want to :)
BTW I don't know why
@#pragma GCC diagnostic ignored “-Wformat”@
didn't work, because the compiler "read" this line AFTER -Wall ...
Sorry to say that because it won't help you so much, but if I were you, I wouldn't suppress the Wreorder warning... Can't you just reorder ? I think it's more safe ! It's very hard to debug !
The problem is that all these warnings belongs to the openni library, so I don't want to modify it.
However, I have disabled all the warnings and then re-enabled the others.
Thanks a lot!