C/C++ Programmer's Guide (G06.27+, H06.08+, J06.03+)

Structures
All TAL and C structures begin on a word boundary. These are guidelines for sharing TAL and C
structures and passing them as parameters:
Specify the same layout for corresponding TAL and C structures.
Specify compatible data types for each item of both structures.
In TAL, pass structures by reference.
In C, use the & (ampersand) operator.
In TAL, a routine cannot return a structure as a return value.
This TAL and C structures have compatible layouts:
TAL Code C Code
STRUCT rec (*); struct birdname
BEGIN {
INT x; short x;
STRING y[0:2]; char y[3];
END; } robin[10];
STRUCT .EXT robin(rec)[0:9];
This TAL and C structures have compatible layouts:
TAL Code C Code
STRUCT rec1 (*); struct rec1
BEGIN {
STRING a, b, c; char a, b, c;
END; };
This TAL and C structures also have compatible layouts:
TAL Code C Code
STRUCT rec2 (*); struct rec2
BEGIN {
STRING e; char e;
INT y; short y;
STRING g; char g;
END; };
Multidimensional Arrays
In C, you can declare multidimensional arrays. In TAL, you can emulate multidimensional arrays
by declaring structures that contain arrays.
Here is an example of multidimensional arrays in TAL and TNS C (large-memory model):
TAL Code C Code
STRUCT rec1 (*);
BEGIN
INT y[0:4]; short cma[10][5];
END;
STRUCT .EXT tma(rec1)[0:9];
!Sample access! /* sample access */
tma[8].y[3] := 100; cma[8][3] = 100;
Arrays of Structures
If you specify bounds when you declare a TAL structure, you create an array of structures. This TAL
and C arrays of structures are equivalent. Each declaration contains an array of ten structure
occurrences:
TAL Code C Code
STRUCT cell (*); struct cell
BEGIN {
INT x; short x;
STRING y; char y;
Interfacing to TAL 111