[Bf-committers] new round of warning hunt : some goofy things i cant decide on
Robert Wenzlaff (AB8TD)
rwenzlaff at soylent-green.com
Sat Jun 4 18:10:43 CEST 2005
On Saturday 04 June 2005 07:29, Vio wrote:
> Duh. I've heard somewhere that *casts* is a way to cheat the compiler,
> but then again, if you
> want your code to compile, what other choice is there (besides hacking
> the offending sources)?
Well, casting ensures that compiler will do what you intended. It's not just
hiding a warning. There are a set of rules built into the language that
determine when to promote or demote variables between differeent types. The
rules attempt to be "fail-safe", but can not be all-inclusive, though. And I
don't waste my time memorizing a bunch of precidence tables when typing in a
cast will do.
Then again, once you use a cast, you have completely abandoned the "fail-safe"
rules and are on your own. So make sure you understand what is being
attempted before you hush the warnings with a cast. You might be hiding
something that needs to really be fixed. C'est la C.
int i = *(short *)(&((&my_float)[1]));
might be syntactically OK, but it won't do what you think it will (unless you
are trying to cause a segfault).
--
************************************************************
If the source code is of any help to a cracker in decrypting
a data stream, then the binary wasn't particularly helpful
to the user when encrypting it.
************************************************************
Robert Wenzlaff rwenzlaff at soylent-green.com
More information about the Bf-committers
mailing list