Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Suppress qmake warning for external headers
QtWS25 Last Chance

Suppress qmake warning for external headers

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 1.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tellien
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tellien
      wrote on last edited by
      #2

      < up >

      1 Reply Last reply
      0
      • Chris KawaC Offline
        Chris KawaC Offline
        Chris Kawa
        Lifetime Qt Champion
        wrote on last edited by
        #3

        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 )
        
        1 Reply Last reply
        2
        • T Offline
          T Offline
          tellien
          wrote on last edited by
          #4

          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.

          Chris KawaC 1 Reply Last reply
          0
          • T tellien

            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.

            Chris KawaC Offline
            Chris KawaC Offline
            Chris Kawa
            Lifetime Qt Champion
            wrote on last edited by
            #5

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

            1 Reply Last reply
            1

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved