tool hunt

N

Noah Roberts

Is there anything that will hunt down c-style casts and replace them
with the appropriate new-style cast?
 
C

Christopher Pisz

Noah Roberts said:
Is there anything that will hunt down c-style casts and replace them with
the appropriate new-style cast?

I dont know how anything but a compiler would know the differance between
(int *)somevar and foo(int *). I Imagine there are warning levels cause the
compiler to spew warnings about c style casts. At least in VS. I am not sure
about others. You'd have to check the docs.
 
I

Ivan Vecerina

: Is there anything that will hunt down c-style casts and replace them
: with the appropriate new-style cast?

Unfortunately, it pretty much would take a compiler to select the
proper new-style cast -- an automated tool would need to properly
disambiguate the cast from similar constructs, and to be aware
of inheritance etc.
So the best approach I could think of -- if you really care to
"upgrade" the code -- would be to manually go through the list
of C casts (can trigger a warning with various compilers), then
use a set of editor macros to convert to a new-style cast with
minimal keystrokes... no better idea unfortunately.

Ivan
 
I

Ioannis Vranos

Noah said:
Is there anything that will hunt down c-style casts and replace them
with the appropriate new-style cast?

My opinion is, if the code is OK, do not bother to modify the casts. Use
the newest C++ casts in your new code.
 
N

Noah Roberts

Ivan said:
would be to manually go through the list
of C casts (can trigger a warning with various compilers)

Anyone know if MSVC has such a warning? I can't find one.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top