For compatibility with Microsoft Windows compilers, GCC supports a
#pragma directives which change the maximum alignment of
members of structures (other than zero-width bitfields), unions, and
classes subsequently defined. The n value below always is required
to be a small power of two and specifies the new alignment in bytes.
)simply sets the new alignment.
#pragma pack()sets the alignment to the one that was in effect when compilation started (see also command-line option -fpack-struct[=n] see Code Gen Options).
])pushes the current alignment setting on an internal stack and then optionally sets the new alignment.
#pragma pack(pop)restores the alignment setting to the one saved at the top of the internal stack (and removes that stack entry). Note that
])does not influence this internal stack; thus it is possible to have
#pragma pack(push)followed by multiple
)instances and finalized by a single
Some targets, e.g. i386 and powerpc, support the
#pragma which lays out a structure as the documented
#pragma ms_struct onturns on the layout for structures declared.
#pragma ms_struct offturns off the layout for structures declared.
#pragma ms_struct resetgoes back to the default layout.