Re: The joy of type aliasing and C

"Alen Ladavac" <[email protected]>
Newsgroups gmane.games.devel.general
Message-ID <[email protected]>
> Yep:
> int _fpclass(double);

Yes of course. But, the purist argument was "this is not portable". Heck, I
think checking out the bits of *(int*)&f is much more portable than
_fpclass(). ;)

> BTW I tend to write this:
>
>     int x = ( int & ) f;
>
> instead of:
>
>     int x = * ( int * ) &f;
>
> Any known difference ?

AFAIK, references are just syntactic sugar, so I see no reason why there
should be a semantic difference. But then again, recasting across a char*
before casting to int* shouldn't make a difference either (logically), but
according to the standard it does. :/

Anyway, using something like:

inline int &FloatAsInt(float &f) { return (int&)f; }

should allow you to fix it by putting a lot of #ifs in there if you have
problems with particular compiler(s) later.

--
Alen



-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
_______________________________________________
Gamedevlists-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gamedevlists-general
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_id=557
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.