-Wextra真的有用吗? [英] -Wextra how useful is it really?

查看:175
本文介绍了-Wextra真的有用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我正在阅读gcc手册,尤其是关于警告/错误标志的部分。在阅读关于-Wextra标志的部分之后,我想知道它是否有用。似乎它抱怨的东西似乎是相当主观的或者是品味的问题。我没有那么熟悉gcc,我只是不时地在大学的一些小项目中使用它,所以对于所有有经验的C / C ++(或者使用gcc的任何语言),与Wextra有什么关系? p>

解决方案

-Wextra 其他内容意味着 -Wtype-limits
$ b


如果比较始终为真或者
始终为假,则警告由于数据类型的限制范围
,但不要警告
常量表达式。例如,如果一个无符号变量是
,用'<'或
'> ='与零相比,
会发出警告。这个警告也是由
-Wextra启用的。


我发现这个非常有用


I'm reading the gcc manual at the moment, especially the part about warning/error flags. After reading the part about the -Wextra flag, I wonder if it is useful at all. It seems that it complains about things which seem to be rather subjective or a matter of taste. I'm not that experienced with gcc, I only use it from time to time for some small projects at university, so to all experienced C/C++ (or for whatever language you use gcc), what's the deal with -Wextra?

解决方案

-Wextra, among other stuff implies -Wtype-limits:

Warn if a comparison is always true or always false due to the limited range of the data type, but do not warn for constant expressions. For example, warn if an unsigned variable is compared against zero with '<' or '>='. This warning is also enabled by -Wextra.

I find this really useful.

这篇关于-Wextra真的有用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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