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

STRING and char Variables
TAL STRING and C char simple variables each occupy one byte of a word. These are STRING
and char compatibility guidelines:
Share variables of type TAL STRING and C char by using pointers.
Declare TAL STRING and C char formal parameters as reference parameters to avoid these
value-parameter incompatibility:
When you pass a STRING parameter to a C routine, the actual byte value occupies the
left byte of the word allocated for the C char formal parameter.
When you pass a char parameter to a TAL routine, the actual byte value occupies the
right byte of the word allocated for the TAL STRING formal parameter.
For example, if you declare a TAL STRING formal parameter as a value parameter rather than as
a reference parameter, the TAL routine can access the C char actual parameter only by explicitly
referring to the right byte of the word allocated for the STRING formal parameter:
PROC sample (s);
STRING s; !Declare TAL STRING parameter as a
BEGIN ! value (not reference) parameter
STRING dest;
dest := s[1]; !Refer to right byte of word
END:
Arrays
TAL and C arrays differ:
C ArrayTAL ArrayCharacteristic
Always zeroAny integerLower bound
One or more dimensionsOne dimension *Dimensions
Indirect onlyDirect or indirectDirect or indirect
char arrays and large-memory-model
arrays are byte addressed; all other
arrays are word addressed
STRING arrays and extended indirect
arrays are byte addressed; all other
arrays are word addressed
Byte or word addressing
* TAL structures can emulate multidimensional C arrays, as discussed in Multidimensional Arrays
(page 111).
To declare compatible TAL and C arrays:
Use data types and alignments that satisfy both compilers.
Declare TAL arrays that have a lower bound of 0.
Declare one-dimensional C arrays.
Declare indirect TAL arrays.
These are compatible arrays in TAL and TNS C (large-memory model):
TAL Code C Code
INT .EXT robin[0:9]; short robin [10];
INT(32) .EXT gull[0:14]; long gull [15];
STRING .EXT grebe[0:9]; char grebe [10];
110 Mixed-Language Programming for TNS Programs