 |
» |
|
|
 |
This section describes default data storage allocation and
alignment for HP compiler data types. Data storage refers to the size of data types, such as bool, short, int, float, and char*. Data alignment refers to the way the HP compiler
aligns data structures in memory. Data type alignment and storage
differences can cause problems when moving data between systems
that have different alignment and storage schemes. These differences
become apparent when a structure is exchanged between systems using
files or inter-process communication. In addition, misaligned data
addresses can cause bus errors when an attempt is made to dereference
the address. Table 2-2 “Size and Alignment of HP Compiler Data Types” lists the size
and alignment of the HP compiler data types: Table 2-2 Size and Alignment of HP Compiler Data Types Data Type | Size (in bytes) | Alignment |
|---|
| bool | 1 | 1-byte | char, unsigned char, signed char | 1 | 1 | wchar_t | 4 | 4 | short, unsigned short, signed short | 2 | 2 | int, unsigned int | 4 | 4 | long, unsigned long | 4* | 4* | float | 4 | 4 | __float80 | 16 | 16 | __float128 | 16 | 16 in +DD64. 8 otherwise. | double | 8 | 8 | | long double | 16 | 8** | long long, unsigned long long | 8 | 8 | enum | 4 | 4 | arrays | Size of array element type | Alignment of array element type | struct | *** | 1-, 2-, 4-, 8-, or 16-byte | | union | *** | 1-, 2-, 4-, 8-, or 16-byte | bit-fields | Size of declared type | Alignment of declared type | pointer | 4* | 4* | * In 64-bit mode, long, unsigned long, and pointer data types are 8 bytes long and 8-byte aligned. **
In 64-bit mode, long double is 16-byte aligned. *** struct and union alignment are same and follow strict alignment
of any member. Padding is done to a multiple of the alignment size. |
|