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

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 pTAL structure, you create an array of structures. This
pTAL and C arrays of structures are equivalent. Each declaration contains an array of ten structure
occurrences:
pTAL Code C Code
STRUCT cell (*); struct cell
BEGIN {
INT x; short x;
STRING y; char y;
END; };
STRUCT .EXT tcell(cell)[0:9]; struct cell ccell [10];
PROC honey (c); void JOANIE
INT .EXT c (cell); (struct cell *c);
EXTERNAL;
Redefinitions and Unions
Variant records are approximated by pTAL structure redefinitions and C unions.
An pTAL redefinition declares a structure item that uses the same memory location as an existing
structure item. The existing structure item can be a simple variable, array, substructure, or pointer
that:
Begins on a word boundary
Is at the same BEGIN-END level in the structure as the redefinition
Is the same size or larger than the redefinition
A C union defines a set of variables that can have different data types and whose values alternatively
share the same portion of memory. The size of a union is the size of its largest variable; the largest
item need not come first.
Although a union typically begins on a word boundary, native C sometimes misaligns numeric
data that is inside a union. In a union, a numeric data item (short, long, int, or long long) is
misaligned if the data item is at an odd byte offset from the beginning of the union, and the union
itself begins at an odd byte address. If possible, you should rearrange the data structure to ensure
that unions begin on an even byte address (and therefore, NMC or CCOMP does not insert an
implicit filler byte).
A union typically, but not always, begins on a word boundary. If FIELDALIGN SHARED2 is in
effect, and if the union contains only character data, a union might begin on an odd-byte (that is,
not be word-aligned).
Pointers
Pointers contain memory addresses of data. You must store an address into a pointer before you
use it. In pTAL and C pointer declarations, you specify the data type of the data to which the
pointer points. You must use pointers when sharing global variables. You can pass pointer contents
by value between pTAL and C routines.
Differences between pTAL and C pointers include:
pTAL structure pointers can point to a byte or word address.
C structure pointers always point to a byte address.
pTAL pointers are dereferenced implicitly.
Here are examples of pTAL and native C pointers:
136 Mixed-Language Programming for TNS/R and TNS/E Native Programs