有没有什么办法让GCC或铛警告的显式转换? [英] Is there any way to get gcc or clang to warn on explicit casts?

查看:107
本文介绍了有没有什么办法让GCC或铛警告的显式转换?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要做的是找到所有类型显式转换双重或浮动到任何其他类型的一些源文件,我有。是否有一个内置的海湾合作​​委员会的方式来做到这一点?
语言是C.
谢谢!

What I'm trying to do is find all explicit casts from type double or float to any other type in some source files I have. Is there a built-in gcc way to do this? Language is C. Thanks!

推荐答案

由于强制转换有明确的法律,并执行怪异的转换以正确的方式,这是极不可能的,GCC将包含一个选项,以警告他们。

Since casts are explicitly legal, and the right way to perform weird conversions, it's highly unlikely that gcc would contain an option to warn about them

相反,这取决于你的来源是如何巨大,你也许能蒙混过关:

Instead, depending on how huge your source is, you might be able to get away with:

grep '\(double|float\) ' *

给你所有的双重或浮动的变量。因为C不是一个普通的语言,这是不平凡的(带外壳工具)来解析成双层或float变量列表,但如果你的来源是足够小,做手工,这是很容易。

to give you all of the double or float variables. Since c isn't a regular language, it's not trivial (with shell tools) to parse this into a list of double or float variables, but if your source is small enough, doing this by hand is easy.

grep '([^()]*)[ ()]*\(your list of variable names\)' *

从那里会告诉你许多你的类型转换。

From there would show you many of your casts.

这篇关于有没有什么办法让GCC或铛警告的显式转换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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