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-26
Variables and Parameters
TNS C Routines as Parameters to TAL
You can call TAL routines and pass TNS C routines as parameters. You can call a TAL 
entry-point identifier as if it were the routine identifier. TNS C routines cannot be 
nested. 
When a called TAL routine in turn calls a TNS C routine received as a parameter, the 
TAL routine assumes that all required parameters of the TNS C routine are value 
parameters. The TAL compiler has no way of checking the number, type, or passing 
method expected by the TNS C routine. If the TNS C routine requires a reference 
parameter, the TAL routine must explicitly pass the address by using:
•
The @ operator for a small-memory-model parameter
•
The $XADR standard function for a large-memory-model parameter
In the following example, a TNS C large-memory-model module contains TNS C 
routine C_PARAM_FUNC, which is to be passed as a parameter. The TAL module 
contains:
•
An EXTERNAL procedure declaration for C_PARAM_FUNC
•
TAL_PROC, which expects C_PARAM_FUNC as a parameter
•
TAL_CALLER, which calls TAL_PROC and passes C_PARAM_FUNC as a 
parameter 
TAL Module
INT i;
STRING .EXT s[0:9];
PROC c_param_func (i, s) !EXTERNAL procedure declaration
 LANGUAGE C; ! for C routine expected as 
 INT i; ! a parameter
 STRING .EXT s; !Extended indirection for large-
 EXTERNAL; ! memory-model 
PROC tal_proc (x); !TAL routine that expects
 PROC(32) x; ! a large-memory-model C routine
 BEGIN ! as a parameter
 CALL x (i, $XADR (s));
 END;
PROC tal_caller;
 BEGIN
 CALL tal_proc (c_param_func);
 END;
PROC m main;
 BEGIN
 CALL tal_caller;
 END;
C Module
void C_PARAM_FUNC (short i, char * s)
{ /* C routine to be passed as */










