[SOLVED] W4 warning level



  • 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.



  • Try to change the variable QMAKE_CFLAGS_WARN_ON:

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



  • 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?



  • 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)

    @



  • 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.



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



  • 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.



  • 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.



  • [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?



  • 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
    }
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.