pTAL Reference Manual (G06.24+, H06.09+, J06.03+)
Example 80 Template Structure Declaration
STRUCT inventory (*); ! Template structure
BEGIN ! Structure layout
INT item;
FIXED(2) price;
INT quantity;
END;
In Example 81 (page 141):
• a and b are template structures. The compiler does not allocate space for them.
• a1 and b1 are definition structures, defined using the layouts of template structures a and b,
respectively. The compiler allocates space for a1 and b1.
• STRUCTALIGN(MAXALIGN) in template structure a affects the alignment of definition structures
a1 and b1 and causes a warning (see the comments in the code).
Example 81 Template Structure With STRUCTALIGN(MAXALIGN)
STRUCT A (*) STRUCTALIGN (MAXALIGN) FIELDALIGN (SHARED8);
BEGIN
INT I; ! Located at byte-offset 0 as defined by SHARED8
FILLER 2;
INT(32) J; ! Located at byte-offset 3 as defined by SHARED8
END;
STRUCT A1 (A); ! Base of A1 is guaranteed to be aligned on a
! 16-byte boundary
STRUCT B (*) FIELDALIGN (SHARED8);
BEGIN
INT K;
FILLER 14;
STRUCT A2 (A); ! Base of A2 is guaranteed to be aligned on
! 16-byte boundary. Compiler issues warning
! here because A is declared with STRUCTALIGN
! (MAXALIGN) and B is a SHARED8 structure.
END;
STRUCT B1 (B); ! Base of B1 is guaranteed to be aligned on
! 16-byte boundary because the largest
! alignment of the components of B1 (A2) is
! 16 bytes.
Declaring Referral Structures
A referral structure declaration allocates storage for a structure whose layout is the same as the
layout of a previously declared structure or structure pointer.
Declaring Referral Structures 141