C ++:什么GNU G ++参数? [英] C++: What GNU G++ parameters?

查看:157
本文介绍了C ++:什么GNU G ++参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

C / C ++编译器的最佳编译器警告级别




$ b b

GCC有数千个选项来添加更多警告;我希望 -Wall -Wextra -pedantic 所有有用的,但只是现在我遇见了 -Woverloaded-virtual 这似乎对我很好。

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.

推荐答案

不是完全相同的类别,我总是使用 -Werror 编译来将警告标记为错误。非常有用。

Not quite the same category but I always compile with -Werror to flag warnings as errors. Very useful.

要使用第三方标题,我通过 -isystem code> -I ...否则这些标头中的警告将破坏构建。

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.

还有 -Weffc ++ ,它会警告Meyers的 Effective C ++ 中列出的特定问题。但是,我发现这太苛刻了。例如,它警告不声明虚拟析构函数的基类。理论上,这是非常好的,但我正在使用一个模板库,使用继承代码重用(和政策类),显然他们没有(也不需要)虚拟析构函数。

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 ++:什么GNU G ++参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆