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

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

问题描述

可能重复:
C/C++ 编译器的最佳编译器警告级别?

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.

您还使用或推荐哪些其他 G++ 参数?

What other G++ parameters do you use or would you recommend?

推荐答案

不是完全相同的类别,但我总是用 -Werror 编译以将警告标记为错误.很有用.

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

为了使这项工作与第 3 方标头一起使用,我通过 -isystem 而不是 -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天全站免登陆