pTAL Reference Manual (H06.08+)

HP pTAL Reference Manual523746-006
9-1
9 Structures
A structure is a collectively stored set of data items that you can access individually or
as a group. Structures contain structure items (fields) such as simple variables, arrays,
simple pointers, structure pointers, and nested structures (called substructures). The
structure items can be of different data types.
Structures usually contain related data items such as the fields of a file record. For
example, in an inventory control application, a structure might contain an item number,
the unit price, and the quantity on hand.
A structure declaration associates an identifier with one of the kinds of structures listed
in Table 9-1 on page 9-1.
The TNS/E instructions setjmp() and longjmp() require data to be aligned on 16-
byte boundaries. To ensure that this data is aligned on 16-byte boundaries, you must
declare it in a template structure using STRUCTALIGN (MAXALIGN).
Topics:
Structure Layout on page 9-3
Overview of Field Alignment on page 9-5
Field and Base Alignment on page 9-8
Array Alignment in Structures on page 9-13
Structure Alignment on page 9-15
Substructure Alignment on page 9-16
Alignment Considerations for Substructures on page 9-19
FIELDALIGN Clause on page 9-20
FIELDALIGN Compiler Directive on page 9-20
SHARED2 Parameter on page 9-20
SHARED8 Parameter on page 9-22
Reference Alignment With Structure Pointers on page 9-27
STRUCTALIGN (MAXALIGN) Attribute on page 9-32
Table 9-1. Kinds of Structures
Structure Description
Definition Describes a structure layout and allocates storage for it
Template Describes a structure layout but allocates no storage for it
Referral Allocates storage for a structure whose layout is the same as the layout of a
previously declared structure