Re: How to type-pun and why

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Andrew Haley <aph@xxxxxxxxxx> writes:

>It's a gcc extension to ISO C.  

I only found "union casts" among the relevant extensions, but perhaps they
imply that the union trick work? (I'm reluctant to use union casts as they
are illegal outside gcc, but the "union trick" seems to be customary.)

It is tempting to abbreviate the union trick by using pointers, like:

  double d = something;
  uint64_t x = ((union { double d; uint64_t x; } *)&d)->x;

which _seems_ to work - but this is purely anecdotal evidence.
Would this also be guaranteed by the same gcc extension?


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux