Type-punning

Andreas Schwab schwab@suse.de
Wed Jun 27 10:27:00 GMT 2007


Herman Geza <hg211@hszk.bme.hu> writes:

> Yes, it's clear now, thanks.  However, it brings a new question: the 
> standard defines layout-compatible types. For example, if I'm correct, my Vector 
> and Point are layout compatible.  What can I do with layout compatible 
> objects?

You can put them in a union and be able to use the common initial
sequence of either alternative, see 6.5.2.3[#5].  Once you have defined
such a union, objects of either type can alias each other.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



More information about the Gcc mailing list