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

To comply with these guidelines, some structures require that you explicitly add filler to ensure that:
Each field begins at an address that is a multiple of its length.
The total length of a structure is a multiple of the widest field in the structure.
Structures Aligned at Odd-Byte Boundaries
If you attempt to access data at an odd-byte address, the results are undefined, whether the data
is a simple variable or a field of a structure. Your program might or might not trap.
Overview of Field Alignment
This subsection gives you an overview of the FIELDALIGN clause and the FIELDALIGN compiler
directive, and the field alignment parameters SHARED2, SHARED8, PLATFORM, and AUTO.
The FIELDALIGN clause specifies the alignment of a structure and of all substructures that do not
specify a FIELDALIGN clause. For details, see FIELDALIGN Clause (page 127).
The FIELDALIGN compiler directive specifies the default alignment for all structures. It includes the
SHARED2, SHARED8, PLATFORM, and AUTO parameters as well as a NODEFAULT parameter.
For more information, see Chapter 17 (page 367).
When you declare a definition or template structure, you specify (either explicitly using a FIELDALIGN
clause or implicitly according to the current setting of the FIELDALIGN compiler directive) how you
want the compiler to allocate memory for the structure. The field alignment for each such structure
is specified by one of the following parameters to a FIELDALIGN clause or directive:
You use SHARED2 and SHARED8 field alignment for structure data used by processes running in
either pTAL or TAL. You can share data by interprocess communication or by accessing it on a
shared storage medium such as disk or tape.
Your program might use library routines that require that structure data be in a SHARED2 or
SHARED8 format. If you use library routines that include structures that specify SHARED2 or
SHARED8, you might need to declare your structures with the same field alignment as the structures
in the library.
If more than one program uses the same source file, you might want to include a FIELDALIGN
clause on every structure declaration in the source file. This ensures that the field alignment of every
structure is consistent across all programs that compile the source file.
If you do not specify a FIELDALIGN clause, each structure will use the current setting of the
FIELDALIGN compiler directive, which might be different for different compilations.
Topics:
SHARED2 (page 117)
SHARED8 (page 118)
PLATFORM (page 118)
AUTO (page 118)
Differences Between PLATFORM and AUTO (page 119)
SHARED2
FIELDALIGN(SHARED2) directs the compiler to allocate the structure’s fields. Specify
FIELDALIGN(SHARED2) when:
Your process is limited by the available stack space in TAL programs.
You want the structure to hold data (for example, interprocess messages, memory, or files)
that is shared by processes or applications running on a combination of TAL-compiled processes
and RISC and Itanium architectures.
For more information, see FIELDALIGN Clause (page 127) and SHARED2 Parameter (page 128).
Overview of Field Alignment 117