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

END; };
STRUCT .EXT tcell(cell)[0:9]; struct cell ccell [10];
PROC honey (c); void JOANIE
INT .EXT c (cell); (struct cell *);
EXTERNAL;
Redefinitions and Unions
Variant records are approximated by TAL structure redefinitions and C unions. A TAL 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. A union always begins on a word boundary.
Pointers
Pointers contain memory addresses of data. You must store an address into a pointer before you
use it. In TAL and C pointer declarations, 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 TAL and C routines.
Differences between TAL and C pointers include:
TAL structure pointers can point to a byte or word address.
C structure pointers always point to a word address. To pass a C structure pointer to a TAL
routine that expects a byte structure pointer, you must explicitly cast the C pointer to type
char.
TAL pointers are dereferenced implicitly.
C pointers are usually dereferenced explicitly.
Small-memory-model C routines use 16-bit pointers only.
Large-memory-model C routines use 32-bit pointers only, even if the pointers refer to the user
data segment. In global structure declarations, you must specify _lowmem in the storage class
of the declaration.
If a TAL routine expects a 16-bit pointer, the C pointer you pass must refer to an object in user
data space.
Here are examples of TAL and TNS C pointers (large-memory model):
TAL Code C Code
STRUCT rec (*); struct rec
BEGIN {
INT d; short d;
INT .p (rec); struct rec *p;
END; };
BLOCK joe;
INT .EXT joes (rec); struct rec *JOE;
END BLOCK;
PROC tonga (p); void CALEDONIA
INT .EXT p (rec); (struct rec *p)
BEGIN {
!Lots of code /* Lots of code */
END; }
112 Mixed-Language Programming for TNS Programs