[SOLVED] W4 warning level
-
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)
@
-
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.
-
[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
}
@