I have recently switched a project to making use of precompiled headers due to compilation becoming slow. Before doing so, it built without any significant warnings.
由于编译变慢,我最近将项目切换为使用预编译头。在此之前,它没有任何重大警告。
However, after adding all the QT headers I use in my project (of which I use 40-50) to the stdafx.h
file, during building of the solution, when the stdafx.h
file gets built I receive a huge number (1000's) of warning relating to QT functions. In particular, I get a lot of "Warning C4251" e.g.
但是,在我的项目(我使用40-50)中使用的所有QT头文件添加到stdafx.h文件后,在构建解决方案期间,当stdafx.h文件生成时,我收到一个巨大的数字(1000的)有关QT功能的警告。特别是,我得到了很多“警告C4251”,例如
1>c:\Qt\5.9\msvc2015_64\include\QtGui/qrawfont.h(154): warning C4251: 'QRawFont::d': class 'QExplicitlySharedDataPointer' needs to have dll-interface to be used by clients of class 'QRawFont' (compiling source file TitleBar.cpp)
1> c:\ Qt \ 5.9 \ msvc2015_64 \ include \ QtGui / qrawfont.h(154):警告C4251:'QRawFont :: d':类'QExplicitlySharedDataPointer'需要让dll接口供类'的客户使用' QRawFont'(编译源文件TitleBar.cpp)
The other two common warning types (albeit far less) are c4800 and c4244.
另外两种常见警告类型(尽管少得多)是c4800和c4244。
I am using QT 5.9 64-bit, on a Windows 10 box running VS2015,.
我在运行VS2015的Windows 10机箱上使用QT 5.9 64位。
I can obviously just disable them, but I don't really like to do such a thing without understanding why this is happening.
我显然可以禁用它们,但我真的不想做这样的事情而不理解为什么会发生这种情况。
1 个解决方案
#1
0
A lot of cross-platform code creates warnings. It's not always possible to disable them, for example if a parameter is unused, one compiler might warn, if it is artificially used to shut up that warning, another might warn about unreachable code. Then MS warns about things like the C standard string library, which it's often impractical to avoid. You have to remember that MS and Apple have very mixed feeling about something like QT. The last thing they want is to sell undifferentiated platforms for running QT applications on. So there's not much motivation to provide appropriate warnings.
许多跨平台代码会产生警告。并不总是可以禁用它们,例如,如果参数未使用,一个编译器可能会发出警告,如果它被人为地用于关闭该警告,则另一个可能会警告无法访问的代码。然后MS警告C标准字符串库这样的东西,这通常是不切实际的。你必须记住MS和Apple对QT这样的东西有着非常复杂的感觉。他们想要的最后一件事就是销售用于运行QT应用程序的无差别平台。因此提供适当警告的动力不大。
#1
0
A lot of cross-platform code creates warnings. It's not always possible to disable them, for example if a parameter is unused, one compiler might warn, if it is artificially used to shut up that warning, another might warn about unreachable code. Then MS warns about things like the C standard string library, which it's often impractical to avoid. You have to remember that MS and Apple have very mixed feeling about something like QT. The last thing they want is to sell undifferentiated platforms for running QT applications on. So there's not much motivation to provide appropriate warnings.
许多跨平台代码会产生警告。并不总是可以禁用它们,例如,如果参数未使用,一个编译器可能会发出警告,如果它被人为地用于关闭该警告,则另一个可能会警告无法访问的代码。然后MS警告C标准字符串库这样的东西,这通常是不切实际的。你必须记住MS和Apple对QT这样的东西有着非常复杂的感觉。他们想要的最后一件事就是销售用于运行QT应用程序的无差别平台。因此提供适当警告的动力不大。