Tool for finding C-style Casts
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: 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); 回答1: If you're using gcc/g++, just enable a warning for C-style casts: g++ -Wold-style-cast ... 回答2: The fact that such casts are so hard to search for is one of the