[SOLVED] W4 warning level
-
wrote on 10 Oct 2011, 19:57 last edited by
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. -
wrote on 10 Oct 2011, 20:58 last edited by
Try to change the variable QMAKE_CFLAGS_WARN_ON:
@
QMAKE_CFLAGS_WARN_ON -= -W3
QMAKE_CFLAGS_WARN_ON += -W4
@ -
wrote on 11 Oct 2011, 16:54 last edited by
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?
-
wrote on 11 Oct 2011, 18:19 last edited by
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)
@
-
wrote on 11 Oct 2011, 18:56 last edited by
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.
-
wrote on 12 Oct 2011, 08:19 last edited by
Then I currently can't help. These templates throw warnings with W4 in MSVC.
-
wrote on 12 Oct 2011, 14:33 last edited by
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.
-
wrote on 29 Apr 2012, 17:56 last edited by
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 referencedTo 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.
-
wrote on 16 Jul 2012, 18:11 last edited by
[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?
-
wrote on 19 Sept 2012, 23:32 last edited by
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
}
@