Understanding alignment in g++
Ian Lance Taylor
iant@google.com
Mon Feb 16 02:10:00 GMT 2009
Yang Zhang <yanghatespam@gmail.com> writes:
> Is there something analogous to __alignof__ that can tell me the
> required alignment? (E.g., if I'm serializing data and trying to pack
> together everything without padding...)
As far as I know there is no way to ask for the alignment required by
the target machine. However, if you use __attribute__ ((packed)), then
gcc will use the available instructions to retrieve the field: a
misaligned full word read if possible and appropriate, otherwise byte
reads.
Ian
More information about the Gcc-help
mailing list