I am compiling a 3rd party library and don't care to fix the warnings present in the library, but I don't want them polluting the Issues pane in Qt Creator.
I've tried following the advice here, but there is no compiler flag to disable -Wall
after it has been enabled, such as with -Wno-enum-compare
.
After reading this, I tried removing the flag like so:
CFLAGS -= -Wall
But that didn't work either. So I tried this advice:
QMAKE_CXXFLAGS_WARN_OFF -= -Wall
Still nothing.
So I looked in the generated Makefile
and found this:
CFLAGS = -pipe -g -fPIC -Wall -W -D_REENTRANT $(DEFINES)
CXXFLAGS = -pipe -g -fPIC -Wall -W -D_REENTRANT $(DEFINES)
So I tried removing the flag from those two variables:
CFLAGS -= -Wall
CXXFLAGS -= -Wall
Still nothing. How are you supposed to remove this compiler flag?!
Turn off the warning for a project in Visual StudioSelect the Configuration Properties > C/C++ > Advanced property page. Edit the Disable Specific Warnings property to add 4996 . Choose OK to apply your changes.
To suppress this warning use the unused attribute (see Variable Attributes). This warning is also enabled by -Wunused , which is enabled by -Wall . Warn whenever a static function is declared but not defined or a non-inline static function is unused.
Unlike compilation errors, warnings don't interrupt the compilation process. They are not errors from the viewpoint of a programming language, but they may be software bugs. However, many compilers can be customized so that their warnings don't stop the compilation process. Warnings must not be ignored.
The simplest solution is:
CONFIG += warn_off
Thanks to peppe in comments.
The -Wall
flag gets inserted into the Makefile
by these two variables:
QMAKE_CFLAGS_WARN_ON
QMAKE_CXXFLAGS_WARN_ON
So to remove -Wall
, you need to remove it from both of those variables.
QMAKE_CFLAGS_WARN_ON -= -Wall
QMAKE_CXXFLAGS_WARN_ON -= -Wall
warn_off
does just that.
As "peppe" also noted in the comment, the Qt'ish way is this according to the documentation below: CONFIG += warn_off/on
warn_on
: The compiler should output as many warnings as possible. This is ignored if warn_off is specified.
warn_off
: The compiler should output as few warnings as possible.
The CONFIG documentation can be found in here.
The QMAKE_CXXFLAGS_WARN_OFF/ON
variables do not need to be set explicitly as they are handled by qmake.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With