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

Previous VariableNew Structure
Direct structure
Direct array
Standard indirect structure Standard indirect structure
Standard indirect array
Standard structure pointer
Extended indirect structure Extended indirect structure
Extended indirect array
Extended structure pointer
If the previous variable is a structure pointer, the new structure is really a pointer.
Topics:
Structure Variants (page 191)
Memory Usage for Structured Equivalenced Variables (page 192)
FIELDALIGN Clause (page 193)
Structure Variants
You use substructures to declare variant records in structures. pTAL does not detect addresses that
are redefined by equivalenced variant structures.
Example 130 Structure Variants
STRUCT s FIELDALIGN(AUTO);
BEGIN
STRUCT v1;
BEGIN
INT .p; ! .p is 4 bytes
INT q;
END;
STRUCT v2 = v1; ! v2 is equivalenced to v1
BEGIN ! v2 is 4 bytes
INT .EXT e;
END;
END;
When you compile Example 130 (page 191), the compiler allocates 8 bytes, the length of v1.
Although v1 and v2 are different lengths and their fields have different data types, the compiler
does not report an error or a warning. You must ensure that the variants are meaningful for your
algorithms.
The structure in Example 131 (page 192) contains the same variants as the structure in Example 130
(page 191), but the variants are in reverse order.
Declaring Equivalenced Definition Structures 191