在Visual Studio 2008中禁用Qt警告 [英] Disable Qt warnings in Visual Studio 2008
问题描述
我们使用VS 2008专业版和Qt的Visual Studio的插件在开发一个Qt 4.8.4应用程序。我想将警告级别设置为4(所有警告),但是对于我们自己的代码。如果我设置在项目属性警告级别> = 2,我得到几百警告从Qt的头文件,我们的#include
。
We use VS 2008 Professional and the Qt Visual Studio Add-In to develop a Qt 4.8.4 application. I would like to set the warning level to 4 (all warnings), but for our own code only. If I set a warning level >= 2 under project properties, I get several hundred warnings from Qt header files we #include
.
不幸的是,似乎VS没有gcc的-isystem选项。我试图封闭的Qt 的#include
秒之间的#pragma警告(推,0)
和 #pragma warning(pop)
获得有限的成功。自动生成的moc _ *。cpp文件仍然会导致有关Qt头文件中的代码的警告。这也很麻烦。
Unfortunately, it seems VS does not have an equivalent of gcc's -isystem option. I have tried enclosing Qt #include
s between #pragma warning(push, 0)
and #pragma warning(pop)
with limited success. Auto-generated moc_*.cpp files still cause warnings about code in Qt header files. It is also quite cumbersome.
你知道有什么其他方法来实现这一点吗?我发现很难相信所有的Qt / MSVC用户他们的警告静音或建成后通过数百个不相关的警告脱脂。
Do you know of any other way to achieve this? I'm finding it hard to believe all Qt/MSVC users have their warnings muted or skim through hundreds of irrelevant warnings after building.
推荐答案
我发现只有一个做到这一点的方式:触摸几乎所有的Qt头文件,包括的#pragma警告(推,0)
和的#pragma警告(pop)
在正确的位置。我想这一次,但放弃了当下的Qt版本出版。
I found only one way to do this: touch almost every Qt header file and include #pragma warning(push, 0)
and #pragma warning(pop)
at the right positions. I tried this once but gave up when the next Qt version was published.
,以减少警告另一种可能性是禁用正确的qmake.conf文件中的特定警告(例如,在。mkspecs\win32-msvc2010)
Another possibility to reduce warnings is to disable specific warnings in the correct qmake.conf file (e.g. in mkspecs\win32-msvc2010).
我在这个文件改变了一些行:
I have changed some lines in this file:
QMAKE_CFLAGS_WARN_ON = -W4 -w34100 -w34189 -wd4127 -wd4512
QMAKE_CFLAGS_RELEASE = -Ox -MD
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -Ox -MD -Zi
QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON
这篇关于在Visual Studio 2008中禁用Qt警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!