/Zp (Struct Member Alignment)
Controls how the members of a structure are packed into memory and specifies the same packing for all structures in a module.
/ZpN option tells the compiler where to store each structure member. The compiler stores members after the first one on a boundary that's the smaller of either the size of the member type, or an N-byte boundary.
The available packing values are described in the following table:
|1||Packs structures on 1-byte boundaries. Same as
|2||Packs structures on 2-byte boundaries.|
|4||Packs structures on 4-byte boundaries.|
|8||Packs structures on 8-byte boundaries (default for x86, ARM, and ARM64).|
|16||Packs structures on 16-byte boundaries (default for x64 and ARM64EC).|
Don't use this option unless you have specific alignment requirements.
The C/C++ headers in the Windows SDK assume the platform's default alignment is used. Don't change the setting from the default when you include the Windows SDK headers, either by using
/Zp on the command line or by using
#pragma pack. Otherwise, your application may cause memory corruption at runtime.
You can also use the
pack pragma to control structure packing. For more information about alignment, see:
To set this compiler option in the Visual Studio development environment
Open the project's Property Pages dialog box. For details, see Set C++ compiler and build properties in Visual Studio.
Select the Configuration Properties > C/C++ > Code Generation property page.
Modify the Struct Member Alignment property.