pTAL Conversion Guide

Structures
pTAL Conversion Guide527302-002
11-24
Arrays in Structures
Arrays 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; therefore, 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.
The layouts and base alignments of s1 and s2 are identical :
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;
Arrays of Structures and Substructures
An array of structures or substructures is the same as an array of a pTAL data type.
The width of the widest field of an element of such an array, combined with the
FIELDALIGN parameter you specify, determines the required alignment of the
structure or substructure and of its fields.