MSVC++ warning flags(MSVC++ 警告标志)
问题描述
使用 gcc 和 clang,我经常使用 -Wall -Wextra 警告标志.
With gcc and clang, I routinely use -Wall -Wextra warning flags.
Visual C++ 2010(和更新版本,如果有差异)的哪些命令行开关会产生大致相同的结果?
What command line switches for Visual C++ 2010 (and newer, if there are differences) would produce about same result?
此 MSDN 文档页面提供了技术细节,但我根据实际经验从 Visual C++ 开发人员那里得到了更定性的答案:经验法则"标志,您可以在开始时安全地投入任何新项目,但仍会捕获大致相同的内容其他编译器的 -Wall -Wextra 捕获.
This MSDN document page provides the technical details, but I am after a more qualitative answer from Visual C++ developers, based on practical experience: A "rule of thumb" flags you can safely throw on any new project when you start, that would still catch approximately the same things that -Wall -Wextra of the other compilers catch.
推荐答案
我同意@Paulius 的回答 这里 您在评论中链接到了./W4 将向您显示默认情况下未禁用的所有警告,这可能是您无需单独搜索每个警告并启用等效项即可获得的最接近大致相同的事物"的警告.MSVC 中的/Wall 将按照它所说的去做并打开所有警告(即使是有问题的警告),这对于任何重要的项目都会产生误报.这与 gcc -Wall 不同,后者只会打开不有问题"的警告.
I agree with @Paulius's answer here which you linked to in the comments. /W4 will show you all warnings that are not disabled by default, which is probably the closest you can get to "approximately the same things" without searching through each of the warnings individually and enabling the equivalent. /Wall in MSVC will do what it says and turn on all warnings (even the questionable ones), which for any non-trivial project will give false positives. This is different from gcc -Wall, which will only turn on warnings that are not "questionable".
这篇关于MSVC++ 警告标志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:MSVC++ 警告标志
基础教程推荐
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- CString 到 char* 2021-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
