HP C Programmer's Guide (92434-90009)

Chapter 2 23
Storage and Alignment Comparisons
Alignment Rules
of padding between c and i, even with NOPADDING alignment mode (see Figure 2-5. on
page 23.)
Figure 2-5. Example of NATURAL Alignment for Structure bar
HPUX_WORD Alignments
For HPUX_WORD alignments:
Alignment for char and short bit-fields is identical to that of HPUX_NATURAL.
Alignment for any other bit-fields (int, long long, enum, for example) is identical to
DOMAIN bit-field alignment.
Note that alignment of a char or short bit-field may not be the same as alignment of a char
or short enum bit-field under the same circumstances.
For example:
#pragma HP_ALIGN HPUX_WORD
char enum b {a};
struct s {
int int_bit :30;
char char_bit :5;
};
struct t {
int int_bit :30;
char enum b char_enum_bit: 5;
};
int main()
{
struct s basic_str;
struct t enum_str;
}
Compilation with the +m option gives the following map:
Identifier Class Type Address
--
basic_str auto struct s SP-48
int_bit member int 0x0 @ 0x0
char_bit member char 0x4 @ 0x0
enum_str auto struct t SP-42
int_bit member int 0x0 @ 0x0
char_enum_bit member enum 0x3 @ 0x6
Both structures have a resulting size of 6 bytes, with 2-byte alignment as shown in Figure
2-6. on page 24.