C/C++ Programmer's Guide (G06.25+)
Mixed-Language Programming for TNS Programs
HP C/C++ Programmer’s Guide for NonStop Systems—429301-008
7-18
Variables and Parameters
•
Declare TAL STRING and C char formal parameters as reference parameters to 
avoid the following 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 as follows:
* TAL structures can emulate multidimensional C arrays, as discussed in Multidimensional Arrays on 
page 7-20.
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.
The following 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];
Characteristic TAL Array C Array
Lower bound Any integer Always zero
Dimensions One dimension * One or more dimensions
Direct or indirect  Direct or indirect Indirect only
Byte or word addressing STRING arrays and 
extended indirect arrays are 
byte addressed; all other 
arrays are word addressed
char arrays and large-
memory-model arrays are 
byte addressed; all other 
arrays are word addressed










