pTAL Reference Manual (H06.03+)

Structures
HP pTAL Reference Manual523746-005
9-37
Declaring Template Structures
AUTO
specifies that the structure and the fields of the structure be aligned according
to the optimal alignment for the architecture on which the program will run (this
is not the same behavior as the AUTO attribute has in the native mode HP C
compiler).
PLATFORM
specifies that the structure and the fields of the structure must begin at
addresses that are consistent across all languages on the same architecture.
A template structure has meaning only when you refer to it in the subsequent
declaration of a referral structure, referral substructure, or structure pointer. The
subsequent declaration allocates space for a structure whose layout is the same as the
template layout.
The declaration in Example 9-29 on page 9-37 associates an identifier with a template
structure layout but allocates no space for it.
In Example 9-30 on page 9-37:
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 9-29. Template Structure Declaration
STRUCT inventory (
*
); ! Template structure
BEGIN ! Structure layout
INT item;
FIXED(2) price;
INT quantity;
END;
Example 9-30. Template Structure With STRUCTALIGN(MAXALIGN) (page 1 of 2)
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