The MIDL compiler requires the C compiler to support a packing level of 1, 2, 4, or 8. The command-line option for Microsoft C compilers that controls packing is /Zplevel, where level is the packing level 1, 2, 4, or 8. The following rules govern the alignment of compound types:
As an example, consider a compound type consisting of a 1-byte character, an integer 4 bytes long, and a 1-byte character:
struct mystructtype {
char c1; /* requires 1 byte */
long l2; /* requires 4 bytes */
char c3; /* requires 1 byte */
} mystruct;
For packing level 4, the structure mystruct is aligned on a (0 mod 4) boundary and sizeof(struct mystructtype) = 12.
For packing level 2, the structure mystruct is aligned on a (0 mod 2) boundary and sizeof(struct mystructtype) = 8.