How to identify wrong cast in a huge C++ unmanaged application?
The Application has thousand of classes. I thought to convert all c-style cast to dynamic cast by regular expression but I failed because it is very difficul开发者_Go百科t identify the Casts's argument expression.
I am using VS2010 (but a have a ready previous version on VS 2008 too)
Do you know a Tool exists that perform the cast check ?
Thanks for any hint
g++ has an option that, when enabled, prints out warnings for c-style casts.
-Wold-style-cast (C++ and Objective-C++ only)
Warn if an old-style (C-style) cast to a non-void type is used within a C++ program. The new-style casts (dynamic_cast, static_cast, reinterpret_cast, and const_cast) are less vulnerable to unintended effects and much easier to search for.
I'd recommend PC-lint - it produces messages for this and a lot more.
精彩评论