今天我尝试使用 -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/