c++ - 使用 -Wall 编译 c++ - 来自其他文件的警告

标签 c++

今天我尝试使用 -WALL 选项编译我的项目,但我收到了很多警告,例如 600,但所有警告似乎都来自标准库文件,例如

项目属性 -> C/C++ -> 常规 -> 警告级别 -> Wall

Warning 14  warning C4820: '_wfinddata64_t' : '4' bytes padding added after data member '_wfinddata64_t::attrib'    c:\program files\microsoft visual studio 11.0\vc\include\wchar.h    118
Warning 15  warning C4820: '_stat32' : '2' bytes padding added after data member '_stat32::st_gid'  c:\program files\microsoft visual studio 11.0\vc\include\wchar.h    507
Warning 16  warning C4820: 'stat' : '2' bytes padding added after data member 'stat::st_gid'    c:\program files\microsoft visual studio 11.0\vc\include\wchar.h    523
Warning 17  warning C4820: '_stat32i64' : '2' bytes padding added after data member '_stat32i64::st_gid'    c:\program files\microsoft visual studio 11.0\vc\include\wchar.h    539
Warning 18  warning C4820: '_stat32i64' : '4' bytes padding added after data member '_stat32i64::st_rdev'   c:\program files\microsoft visual studio 11.0\vc\include\wchar.h    540

这正常吗?为什么我会收到来自其他文件的警告?

最佳答案

在 Visual Studio 下,/Wall 实际上会生成比任何人都关心的更多警告 - 通常在调试一个非常模糊的问题并需要确定是否看到 Visual Studio bug 或非常奇怪的边缘情况时使用它在低级代码中。

您可能应该使用/W3,它大约相当于 GCC/Clang 的 -Wall。如果您打算非常勤奋,则可以选择/W4。/W3 通常会在其他人的代码中显示警告,/W4 会警告深奥的事情,例如未引用的形式参数,但也会警告一些有用的情况,例如隐藏变量。

关于c++ - 使用 -Wall 编译 c++ - 来自其他文件的警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35528689/

相关文章:

c++ - 什么时候使用 boost thread join 函数?

c++ - 定义线程函数时的 std::thread 表示法

c++ - 使用 Media Foundation 制作视频

c++ - 是否可以将 native UI 带入 Cocos2dx

c++ - 我们可以将字符串用于高精度 float 吗?

c++ - 创建一个越界数组

c++ - 编译成功后找不到openni2库

c++ - 如何 typedef 嵌套容器的迭代器?

c++ - eclipse /bin/sh : g++: command not found

c++ - C++中长数字的单独数字