K
Kenny McCormack
Richard said:Kenny McCormack said:
However, I and it looks like a few others don't see it your way that
unions are not topical.
Whoever said that?
What *I* said, which you may have misunderstood, was that there's no
*use* of unions that is topical here that can't just as easily be done
with a struct.
Counter-example:
union U { double d; unsigned char ir[sizeof(double)]; };
union U u;
size_t i;
u.d = 3.14159;
for(i = 0; i < sizeof(double); i++)
{
printf("%02X", u.ir);
}
putchar('\n');
struct S {int foo;}; /* need to use struct somewhere */
double d = 3.14159;
unsigned char ir[sizeof (double)];
memcpy (ir, &d, sizeof d);
...
Now Richard should probably say that it's not as easy, to remain
right.
Yevgen
Heathfield will remain right in his own mind regardless of any possible
real world events. He's the Usenet equivalent of the "flesh wound"
knight in the Holy Grail.