HP C Programmer's Guide (92434-90009)

Chapter 2 19
Storage and Alignment Comparisons
Alignment Rules
in Figure 2-1. on page 19
Figure 2-1. Example of HPUX_WORD/DOMAIN_WORD Alignment for Structures
HPUX_NATURAL/DOMAIN_NATURAL Alignments
For HPUX_NATURAL and DOMAIN_NATURAL alignments, the alignment of structure and union
types is the same as the strictest alignment of any member. Therefore, they may be aligned
on 1-, 2-, 4-, or 8-byte boundaries. Padding is performed as necessary so that the size of the
object is a multiple of the alignment size.
For example, the declaration shown in the previous section will now be aligned:
Identifier Class Type Address
--
s ext def struct st
c member char 0x0 @ 0x0
l member long int 0x4 @ 0x0
d member char 0x8 @ 0x0
b member short int 0xa @ 0x0
i member ints [2] 0xc @ 0x0
In this case, the size of the structure is 20 bytes, and the entire structure is aligned on a
4-byte boundary since the strictest alignment is 4 (from the int and long types), as
illustrated in Figure 2-2. on page 19.
Figure 2-2. Example of HPUX_NATURAL/DOMAIN_NATURAL Alignment for
Structures
HPUX_NATURAL_S500 Alignments
For HPUX_NATURAL_S500 alignments, series 500 computers align structures on 2- or 4-byte
boundaries, according to the strictest alignment of its members. As with the other