TAL Programmer's Guide
TAL and C Guidelines
Mixed-Language Programming
096254 Tandem Computers Incorporated 17–21
Substructures
The TAL compiler allocates alignment of substructures on a byte or word boundary as
follows:
Each definition substructure occurrence is byte aligned if the first item it contains
begins on a byte boundary.
Each definition substructure occurrence is word aligned if the first item it contains
begins on a word boundary.
Each referral substructure occurrence is always word aligned.
C substructures always begin and end on word boundaries.
In this example, TAL referral substructure TSUB and C substructure CSUB have
compatible layouts:
TAL Code C Code
STRUCT rec1 (
*
); struct rec1
BEGIN {
STRING a, b, c; char a, b, c;
END; };
STRUCT rec3 (
*
); struct rec3
BEGIN {
INT x; short x;
STRING var; char var;
STRUCT tsub (rec1); struct rec1 csub;
STRING f; char f;
END; };
In this example, TAL definition substructure TSUB1 follows a STRING variable and
begins on a byte boundary. The layouts of TSUB1 and CSUB1 are not compatible, so
you cannot share the substructures between the two languages:
TAL Code C Code
STRUCT rec4 (
*
); struct rec4
BEGIN {
INT x; short x;
STRING a; char a;
STRUCT tsub1; struct
BEGIN {
STRING b,c,d; char b,c,d;
END; } csub1;
STRING e; char e;
END; };
If you use the Data Definition Language (DDL) to describe your files, the byte-aligned
substructure layout is the only layout DDL cannot generate. (DDL is described in the
Data Definition Language (DDL)Reference Manual.)