The _Packed qualifier removes padding between members of structures and unions, whenever possible. However, the storage saved using packed structures and unions may come at the expense of runtime performance. Most machines access data more efficiently if it is aligned on appropriate boundaries. With packed structures and unions, members are generally not aligned on natural boundaries, and the result is that member- accessing operations (using the . and -> operators) are slower.
_ Packed can only be used with structures or unions. If you use _Packed with other types, an error message is generated and the qualifier has no effect on the declarator it qualifies. Packed and nonpacked structures and unions have different storage layouts. Comparisons between packed and nonpacked structures or unions of the same type are prohibited.
If you specify the _Packed qualifier on a structure or union that contains a structure or union as a member, the qualifier is not passed on to the contained structure or union.
The IBM C and C++ Compilers also lets you pack structures using the #pragma pack directive or the
option.
C++
does not support the _ Packed keyword. Use the #pragma pack
directive or the compiler option to control the alignment of
structures and unions.