Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. [SOLVED] W4 warning level
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] W4 warning level

Scheduled Pinned Locked Moved Qt Creator and other tools
10 Posts 5 Posters 14.2k Views 1 Watching
  • 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.
  • D Offline
    D Offline
    DSav
    wrote on 10 Oct 2011, 19:57 last edited by
    #1

    Is there a possibility to run compiler with /W4 option using Qt toolchain (qmake → make)? The following line in project file
    @QMAKE_CXXFLAGS += /W4@
    leads to “warning: D9025 : overriding '/W4' with '/W3'” in Build Issues pane.

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on 10 Oct 2011, 20:58 last edited by
      #2

      Try to change the variable QMAKE_CFLAGS_WARN_ON:

      @
      QMAKE_CFLAGS_WARN_ON -= -W3
      QMAKE_CFLAGS_WARN_ON += -W4
      @

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • D Offline
        D Offline
        DSav
        wrote on 11 Oct 2011, 16:54 last edited by
        #3

        QMAKE_CFLAGS_WARN_ON switches have no effect, but using

        @
        QMAKE_CFLAGS_WARN_ON -= -W3
        QMAKE_CFLAGS_WARN_ON += -W4
        @

        does enable -W4 for the compiler (MSVC 2010, if it is important); thank you, Volker, for the advice. The problem is, however, that there‘re a lot of warnings coming from the Qt headers (qlist.h, qhash.h, etc). As far as I’m concerned, there’s no way to disable W4 warnings for library headers, but enable them for a project files. Is that true?

        1 Reply Last reply
        0
        • G Offline
          G Offline
          giesbert
          wrote on 11 Oct 2011, 18:19 last edited by
          #4

          In MSVS, you can use #pragma s to specify enable / disable warnings, "see MSDN":http://msdn.microsoft.com/en-us/library/2c8f766e(v=vs.80).aspx

          @

          #pragma warning(push)
          #pragma warning(disable: 4178 3145)

          // do the masked stuff here

          #pragma warning(pop)

          @

          Nokia Certified Qt Specialist.
          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

          1 Reply Last reply
          0
          • D Offline
            D Offline
            DSav
            wrote on 11 Oct 2011, 18:56 last edited by
            #5

            Yeah, I know this. Unfortunately, using pragma’s in every source file of the project is not the solution here.

            BTW, the project is actually cross-platform and we use not only MSVC, I was just interested in enabling W4 only on MSVC at this time.

            1 Reply Last reply
            0
            • G Offline
              G Offline
              giesbert
              wrote on 12 Oct 2011, 08:19 last edited by
              #6

              Then I currently can't help. These templates throw warnings with W4 in MSVC.

              Nokia Certified Qt Specialist.
              Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

              1 Reply Last reply
              0
              • D Offline
                D Offline
                DSav
                wrote on 12 Oct 2011, 14:33 last edited by
                #7

                Yes, unfortunately it seems there is currently no possiblilty to find the solution.

                I will add [SOLVED] to the title of the thread as I actually received the answer to my question.

                1 Reply Last reply
                0
                • T Offline
                  T Offline
                  tiho_d
                  wrote on 29 Apr 2012, 17:56 last edited by
                  #8

                  I also compile with warning level 4. Instead of suppressing the warnings with #pragma in every file, I suppressed the Qt generated warnings in general for my projects. The Qt warnings at Warning level 4 with VS 2008 are:

                  warning C4127: conditional expression is constant
                  warning C4512: 'QForeachContainer<T>' : assignment operator could not be generated
                  warning C4189: 'concreteNode' : local variable is initialized but not referenced

                  To supress them you can add to your project files:

                  QMAKE_CXXFLAGS += -wd4127 -wd4512 -wd4189

                  Thought this might be a good add on to the topic here.

                  1 Reply Last reply
                  1
                  • G Offline
                    G Offline
                    genefield
                    wrote on 16 Jul 2012, 18:11 last edited by
                    #9

                    [quote author="tiho_d" date="1335722196"]
                    To supress them you can add to your project files:

                    QMAKE_CXXFLAGS += -wd4127 -wd4512 -wd4189[/quote]

                    What exactly do you mean by project files? The .vcproj files?

                    If it is, where exactly would "QMAKE_CXXFLAGS += -wd4127 -wd4512 -wd4189" be added?

                    1 Reply Last reply
                    0
                    • T Offline
                      T Offline
                      tiho_d
                      wrote on 19 Sept 2012, 23:32 last edited by
                      #10

                      genefield: - Sorry for the late reply. QMAKE_CXXFLAGS is a qmake variable so it must be written inside your pro/pri files. As these warnings are VS compiler specific I usually use the following:

                      @
                      win32-msvc2008|win32-msvc2010 {
                      # Enable Level 4 compiler warnings
                      QMAKE_CXXFLAGS_WARN_ON -= -W3
                      QMAKE_CXXFLAGS_WARN_ON += -W4
                      # Hush some known Qt warnings
                      QMAKE_CXXFLAGS += -wd4127 -wd4512 -wd4189
                      }
                      @

                      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