pTAL Reference Manual (G06.24+, H06.09+, J06.03+)
Figure 7 Well-Aligned and Misaligned SHARED8 Structures With Base Alignment of 4
Array Alignment in Structures
When you declare an array in a structure, the alignment of the beginning of the array is the
alignment of the base type of the array. Thus, for example, the field alignment of an array of INTs
is the same as the field alignment of a single INT, which is 2. Declaring an array in a structure is
the same as explicitly declaring individual fields, each with the same data type as the array’s base
type.
In Example 52 (page 122), the layouts and base alignments of s1 and s2 are identical:
Example 52 Arrays Within Structures
STRUCT s1 FIELDALIGN(SHARED8);
BEGIN
INT i;
INT a[0:2];
STRUCT s1[0:1];
BEGIN
INT(32)w;
INT y;
INT x;
END;
END;
STRUCT s2 FIELDALIGN(SHARED8);
BEGIN
INT i;
INT a;
INT b;
INT c;
STRUCT s1a;
BEGIN
INT(32)w;
INT y;
INT x;
END;
STRUCT s1b;
BEGIN
INT(32)w;
INT y;
INT x;
END;
END;
122 Structures