Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Suppress qmake warning for external headers
I am building the program with qmake .pro file. I want to see all the warning via
QMAKE_CFLAGS_WARN_ON = -w -Wall
QMAKE_CXXFLAGS_WARN_ON = -w -Wall
However I am using external libraries, so their headers may not comply with C++17 standard. The compiler has warnings even for windows headers.
How can I add include dirs to list of files to which warnings will be suppressed?
Using MSVC 2017 x64, Qt 5.12.6.
< up >
/Wallcontradicting? The first one suppresses all warnings while the other one shows all. Also
Wallis pretty aggressive on MSVC and even Microsoft guys recommend something like
/W3+ any additional warnings you care about enabled manually with pragmas.
Anyway, I don't think you can specify different flags for different dirs.
The way I usually do it is wrap the troublesome library in a proxy header and surround it with a
#pragma warning, for example
foo.his causing trouble I'd have a
foo_wrapper.hthat does something along the lines of:
#pragma warning( push ) #pragma warning( disable : 4505 ) //or whatever warnings you want to silence #include <foo.h> #pragma warning( pop )
Aren't /w and /Wall contradicting?
-Wall; Turns on lots of compiler warning flags, specifically (-Waddress, -Wcomment, -Wformat, -Wbool-compare, -Wuninitialized, -Wunknown-pragmas, -Wunused-value, -Wunused-value …)
-Wextra or just -W (see more); Enables extra flags not enabled by -Wall, such as -Wsign-compare (C only), -Wtype-limits, -Wuninitialized …
I believe not, but maybe I'm missing something https://caiorss.github.io/C-Cpp-Notes/compiler-flags-options.html.
Anyway I think this can be a feature request to add a configuration option into qmake.
If use adds a path into the variable IGNOREWARNINGSPATH (or similar) all warning coming from these headers will be ignored.