pTAL Reference Manual (G06.24+, H06.09+, J06.03+)

INT(32) c; ! c is field with widest
END; ! alignment: 4
STRUCT s3 FIELDALIGN(SHARED8); ! Base alignment of structure is
BEGIN ! 8 because of FIXED c
STRING a;
STRING b;
FILLER 6;
FIXED c; ! c is field with widest
END; ! alignment: 8
Substructure Alignment
The rules for field alignment of substructures are the same as the rules for structures. You can specify
the field alignment of a substructure explicitly using a FIELDALIGN clause or implicitly by allowing
the field alignment of the substructure to default to the field alignment of the containing structure
or substructure. In either case, the alignment of fields must conform to the rules described previously,
under “Using Field Alignment.” For SHARED8 structures, you must ensure that every field begins
at an appropriate address and that the end of the structure includes filler, if necessary, so that the
total length of the substructure is an integral multiple of its widest field.
The following rules apply to substructures:
A definition substructure that does not specify a FIELDALIGN clause inherits the field alignment
of its containing structure or substructure.
The base alignment of a substructure is the alignment of the widest field of the substructure.
Begin the base of a substructure at an offset that is an integral multiple of the substructure’s
alignment, relative to the start of its containing structure or substructure. If the substructure is
a definition substructure and both the structure and substructure have SHARED8 field alignment,
the substructure must be well aligned.
Example 57 Well-Aligned Structure With Well-Aligned Substructure
STRUCT s FIELDALIGN(SHARED8);
BEGIN
INT i;
FILLER 2; ! ss is 4-byte aligned. Use FILLER 2 to
! force ss to a 4-byte address
STRUCT ss; ! Specified alignment of ss is SHARED8,
BEGIN ! inherited from s
INT(32) m;
INT n;
FILLER 2; ! Alignment of substructure ss is 4
END; ! FILLER 2 makes total length of ss 8
INT j;
STRING t[0:2];
FILLER 3; ! Alignment of structure s is 4: declare
END; ! FILLER 3 to make length of s an integral
! multiple of its widest field
For further information about substructures, see Alignment Considerations for Substructures
(page 126).
124 Structures