Important: Please read the 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
    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 >

  • Moderators

    Aren't /w and /Wall contradicting? The first one suppresses all warnings while the other one shows all. Also Wall is 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
    if header foo.h is causing trouble I'd have a foo_wrapper.h that 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

    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.

  • Moderators

    @tellien This link lists flags for gcc/mingw. You said you're using MSVC, so here's a link for that: MSVC Warning level.

Log in to reply