本文介绍了工具发现C-风格的转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有谁知道一个工具,我可以用它来找到明确的C风格的code蒙上了?我重构了一些C ++ code和希望替换C-风格转换在以往可能。
这是例如C样式转换将是:
富富=(美孚)栏;
在C对比例子++风格的转换将是:
富富=的static_cast<富>(巴);
富富= reinter pret_cast<富>(巴);
富富= const_cast会<富>(巴);
解决方案
如果你正在使用gcc / g ++的,只是启用预警C-风格的转换:
G ++ -WOLD式铸...
Does anyone know of a tool that I can use to find explicit C-style casts in code? I am refactoring some C++ code and want to replace C-style casts where ever possible.
An example C-style cast would be:
Foo foo = (Foo) bar;
In contrast examples of C++ style casts would be:
Foo foo = static_cast<Foo>(bar);
Foo foo = reinterpret_cast<Foo>(bar);
Foo foo = const_cast<Foo>(bar);
解决方案
If you're using gcc/g++, just enable a warning for C-style casts:
g++ -Wold-style-cast ...
这篇关于工具发现C-风格的转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!