This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Understanding alignment in g++
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