C++: What GNU G++ parameters?(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++ 参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:C++:什么 GNU G++ 参数?


- ubuntu下C/C++获取剩余内存 2023-09-18
- c++ const 成员函数,返回一个 const 指针.但是返回的指针是什么类型的 const? 2022-10-11
- C语言qsort()函数的使用方法详解 2023-04-26
- 我应该为我的项目使用相对包含路径,还是将包含目录放在包含路径上? 2022-10-30
- Easyx实现扫雷游戏 2023-02-06
- 详解C语言中sizeof如何在自定义函数中正常工作 2023-04-09
- Qt计时器使用方法详解 2023-05-30
- C语言手把手带你掌握带头双向循环链表 2023-04-03
- C语言详解float类型在内存中的存储方式 2023-03-27
- C++ 数据结构超详细讲解顺序表 2023-03-25