C++:什么是 GNU G++参数?
可能的重复:
C/C++ 编译器的最佳编译器警告级别?
GCC 有数千个添加更多警告的选项;我希望 -Wall
-Wextra
-pedantic
包含所有有用的内容,但现在我遇到了 -Woverloaded-virtual< /code> 这对我来说真的很好。
您还使用或推荐哪些其他 G++ 参数?
Possible Duplicate:
Best compiler warning level for C/C++ compilers?
GCC has thousands of options to add more warnings; I was hoping that -Wall
-Wextra
-pedantic
included all the useful ones, but just now I met -Woverloaded-virtual
which seems really nice to me.
What other G++ parameters do you use or would you recommend?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
不完全相同的类别,但我总是使用
-Werror
进行编译,将警告标记为错误。非常有用。为了使此功能与第 3 方标头一起工作,我通过
-isystem
而不是-I
包含这些标头……否则这些标头中的警告将破坏构建。还有
-Weffc++
,它针对 Meyers 的 Effective C++ 中概述的特定问题发出警告。然而,我发现这太严厉了。例如,它会对未声明虚拟析构函数的基类发出警告。从理论上讲,这非常好,但我正在开发一个模板库,该库使用继承来重用代码(和策略类),显然它们没有(也不需要)虚拟析构函数。Not quite the same category but I always compile with
-Werror
to flag warnings as errors. Very useful.To make this work with 3rd party headers, I include those headers via
-isystem
instead of-I
… otherwise warnings in those headers will break the build.There’s also
-Weffc++
which warns for specific issues outlined in Meyers’ Effective C++. However, I’ve found this too harsh. For example, it warns for base classes that don’t declare virtual destructors. In theory, this is very nice but I’m working on a template library that uses inheritance for code reuse (and policy classes) and obviously they don’t have (nor need) virtual destructors.请参阅C/C++ 编译器的最佳编译器警告级别?。一篇文章包含以下详尽(且令人筋疲力尽)的列表。
See Best compiler warning level for C/C++ compilers?. One post contains the following exhaustive (and exhausting) list.
有些是我见过的,已经被使用过;
Some that I've seen that are used;
一般来说,我启用所有警告,然后有选择地删除那些提供无用输出的标志。在我的一个项目中,我使用以下 C 和 C++ 警告:
此外,我使用以下 C++ 标志:
此外,对于发布版本,我启用以下警告:
我发现
-Wall< /code> 仅启用绝对最少的警告,而不是“全部”,顾名思义。
In general I enable all warnings and then remove those flags selectively that give useless outputs. In one of my projects, I use the following C and C++ warnings:
In addition, I use the following C++ flags:
In addition, for the release build I enable the following warnings:
I find it quite annoying that
-Wall
enables only the absolute minimum of warnings instead of "all", as the name implies.除了上面已经提到的:
In addition to the ones already mentioned above: