My environment:
I want to compile my C++ project with -W4
instead of the default -W3
, so I added this line to my .pro
file:
QMAKE_CXXFLAGS += -W4
But then, I get many of these warnings (one for each compilation unit, I suppose):
cl : Command line warning D9025 : overriding '/W4' with '/W3'
From the command line, I can see that the command line does include both -W3
and -W4
(in this order).
So, my question: How can I swap the order of -W3
and -W4
(so -W4
would take precedence over -W3
)?
Note that this did not work: I tried to modify Qt's configuration file C:\Qt\5.6.2\msvc2015_64\mkspecs\common\msvc-desktop.conf
, by changing the value of variable QMAKE_CFLAGS_WARN_ON
from -W3
to -W4
, and not adding -W4
to QMAKE_CXXFLAGS
in my .pro
file, but that caused many (thousands) of warnings being generated by libraries. I also tried to append -W4
to QMAKE_CXXFLAGS_WARN_ON
(instead of QMAKE_CXXFLAGS
) in my .pro
file, with the same result (thousands of warnings from libraries).
Also note that if I add -Wall
(instead of -W4
) to QMAKE_CXXFLAGS
, then:
-Wall
is
followed by -W3
on the command line)-W3
changed to -W4
in msvc-desktop.conf
(or with -W4
appended to
QMAKE_CXXFLAGS_WARN_ON
in my .pro
file).I use qmake (through Qt Creator), so any solutions that would require editing the generated Visual Studio project files would be unacceptable.
The change to your project file appends the warning setting to the existing variable, which is predefined:
QMAKE_CXXFLAGS += -W4
You could either prepend the variable, or actually replace the existing warning variable setting with your own:
QMAKE_CXXFLAGS ~= s/-W3/-W4