pack Code Generation Option (OS/2, Windows)

Syntax: Default:
gen(pack, alignment) gen(pack, 4)
gen(pack, 8)

This option specifies the alignment or packing of data structures within classes, structures, and unions. You can specify alignment on 1-,2-,4-,8-, or 16-byte boundaries.

By default, structures and unions are aligned on 4-byte boundaries on OS/2.

By default, structures and unions are aligned on 8-byte boundaries on Windows.

No member is forced to an alignment greater than specified with this option. Members are not forced to the specified boundary if the natural alignment is less. For example, the 4-byte long d in the following code is located on a boundary, as shown in the following code:

struct S {
   char c;
   long d:
}

 

alignment boundary for d
gen(pack, 1)
gen(pack, 2)
gen(pack, 4)
gen(pack, 8)
gen(pack, 16)
forced to 1-byte
forced to 2-byte
forced to 4-byte
4-byte natural boundary
4-byte natural boundary

 

For best performance use gen(pack, 8) on OS/2, unless the target module must be compatible with code generated by older OS/2 compilers.

The pack option has no effect on AIX, but the align option provides some control of packing.



Incremental C++ Build
C Compilation
Configuration Files


Set Build Options
Build
Optimize Your Application


Code Generation Options