Table of Contents Previous topic Next topic
C/C++ COMPILER->Compiler command line options->Structure and union packing (/Zp)
Structures members are by default aligned so that long words will be aligned to a long word boundary, words to a word bounday and bytes to a byte boundary. Objects greater than 4 bytes in size will be aligned to a long word boundary. Similarly structures and unions are padded so that this alignment is maintained if the structure or union is an element of an array. The default packing is therefore 4.
You may wish to change this packing either to conserve space or to conform to an existing data structure. The /Zp option allows you to do this across the complete module. Packings of 1, 2, 4, 8, and 16 are supported and so the command line options /Zp1, /Zp2, /Zp4, /Zp8 and /Zp16 can be used.
Use the pack pragma to specify the alignment at the declaration level.
If compiling from with the Embedded Development Studio, the packing can be specified via the Build->Settings->Compiler tab.