/Zp (Struct Member Alignment)
Visual Studio .NET 2003
/Zp[1|2|4|8|16]
The Struct Member Alignment (/Zpn) option controls how the members of a structure are packed into memory and specifies the same packing for all structures in a module. When you specify this option, each structure member after the first is stored on either the size of the member type or n-byte boundaries (where n is 1, 2, 4, 8, or 16), whichever is smaller.
You should not use this option unless you have specific alignment requirements.
| Option | Result |
|---|---|
| /Zp1 | Packs structures on 1-byte boundaries |
| /Zp2 | Packs structures on 2-byte boundaries |
| /Zp4 | Packs structures on 4-byte boundaries |
| /Zp8 | Packs structures on 8-byte boundaries (default) |
| /Zp16 | Packs structures on 16-byte boundaries |
| /Zp | Specifies the same packing for all structures in a module.
/Zp is the same as /Zp1. |
You can also use #pragma pack to control structure packing.
To set this compiler option in the Visual Studio development environment
- Open the project's Property Pages dialog box. For details, see Setting Visual C++ Project Properties.
- Click the C/C++ folder.
- Click the Code Generation property page.
- Modify the Struct Member Alignment property.
To set this compiler option programmatically
See StructMemberAlignment Property.