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

Table Of Contents
Mixed-Language Programming for TNS/R and
TNS/E Native Programs
HP C/C++ Programmer’s Guide for NonStop Systems429301-010
8-24
Differences Between Native and TNS Mixed-
Language Programs
TAL_CALLER, which calls TAL_PROC and passes C_PARAM_FUNC as a
parameter
pTAL 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); !pTAL routine that expects
PROC x; ! a C routine as a parameter
BEGIN
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 */
/* a parameter to TAL_PROC */
}
When you pass a C routine as a parameter, the compiler passes a 32-bit address that
contains PEP and map information in the high-order word and a zero in the low-order
word.
Differences Between Native and TNS Mixed-
Language Programs
The information in this section is for writing mixed-language native C or C++ programs.
If you need to write mixed-language native C or C++ programs that can run as both
TNS and native processes, you must also read Section 7, Mixed-Language
Programming for TNS Programs.