Sun WorkShop Compiler C 5.0 User's Guide

(6.5.2.1)The padding and alignment of members of structures.

Table B-5 Padding and Alignment of Structure Members

Type 

Alignment Boundary 

Byte Alignment 

 char

Byte 

 short

Halfword 

 int

Word 

 long (SPARC) v8

Word 

 long (SPARC) v9 Doubleword 8
 float (SPARC)

Word 

 double (SPARC)

Doubleword (SPARC)

Word (Intel)

8 (SPARC)

4 (Intel)

 long double (SPARC) v8

Doubleword (SPARC)

Word (Intel)

8 (SPARC)

4 (Intel)

 long double (SPARC) v9 Quadword 16
 pointer (SPARC) v8

Word 

 pointer (SPARC) v9 Quadword 8
long long [Not available in -Xc mode.]

Doubleword (SPARC)

Word (Intel)

8 (SPARC)

4 (Intel)

Structure members are padded internally, so that every element is aligned on the appropriate boundary.

Alignment of structures is the same as its more strictly aligned member. For example, a struct with only chars has no alignment restrictions, whereas a struct containing a double would be aligned on an 8-byte boundary.