pTAL Conversion Guide

Structures
pTAL Conversion Guide527302-002
11-27
Considerations
Use SHARED8 structures with care in TNS processes. For example, using the
structure s3 from Example 11-10 on page 11-26, you can declare a structure array
such as:
STRUCT s4(s3) [0:99];
s4 has six bytes of filler for each of its 100 occurrences, a total of 600 bytes of filler.
The same declaration based on s1 would have no extra filler but would be a
SHARED2 structure:
STRUCT s5(s1) [0:99];
Considerations
SHARED2 and SHARED8 structures cannot include fields whose size is different
on TNS and native architectures. In a SHARED2 or SHARED8 structure, you can
include only pointers whose address type is SGBADDR, SGWADDR, or
EXTADDR. Pointers whose address type is any other type are 16 bits on TNS
architecture, but 32 bits on native architecture.
Similarly, if the data type of a nonpointer field in a SHARED2 and SHARED8
structure is an address type, its type must be SGBADDR, SGWADDR, or
EXTADDR:
STRUCT s FIELDALIGN(SHARED2);
BEGIN
INT i; ! OK: i is a simple variable
INT .j; ! ERROR: j's address type is WADDR
BADDR b; ! ERROR: b's data type is BADDR
END;
SHARED2 and SHARED8 structures and substructures cannot include a
substructure whose field alignment is AUTO:
STRUCT s FIELDALIGN(SHARED8);
BEGIN
STRUCT s1 FIELDALIGN(AUTO); ! ERROR: Substructure cannot
BEGIN ! be FIELDALIGN(AUTO)
...
END;
END;
The native compiler pads SHARED2 structures and substructures with an extra
byte if the end of the last field in the structure or substructure ends at an odd-byte
address, unless the structure has one-byte alignment—that is, all fields in the
structure or substructure are STRINGs or UNSIGNED(1-8).
STRING fields in structures can begin at any byte offset.