C/C++ Programmer's Guide (G06.25+)
Mixed-Language Programming for TNS/R and 
TNS/E Native Programs
HP C/C++ Programmer’s Guide for NonStop Systems—429301-008
8-22
Considerations When Interfacing to pTAL
A C routine can share an enumeration variable with pTAL routines. A pTAL routine 
cannot access the enumeration variables, but it can declare LITERALs for readability. 
For example:
pTAL Code C Code
LITERAL no = 0, typedef enum choice 
 yes = 3, { no = 0, 
 maybe = 4; yes = 3, 
 maybe = 4 
BLOCK answer; } choice;
 INT answer_var;
 END BLOCK; choice ANSWER;
A C routine can pass enumeration parameters to pTAL routines, placing the actual 
value in a pTAL INT variable. For example:
pTAL Code C Code
LITERAL no = 0, enum choice {no = 0, 
 yes = 3, yes = 3,
 maybe = 4; maybe = 4 };
 enum choice answer;
PROC tal_proc (n);
 INT n; _tal void TAL_PROC (short);
 BEGIN
 !Lots of code main ()
 IF n = yes THEN ... ; {
 !Lots of code answer = yes;
 END; TAL_PROC (answer);
 /* lots of code */
 }
pTAL Routines as Parameters to C
You can call C routines and pass pTAL routines as parameters. You can pass any 
pTAL routine except EXTENSIBLE or VARIABLE routines as parameters.
A passed pTAL routine can access the routine’s local variables and global pTAL 
variables. The passed routine can contain subprocedures, but they cannot be passed 
as parameters.
In the following example, a C module contains C_FUNC, which expects a pTAL 
procedure as a parameter. The pTAL module contains:
•
An EXTERNAL procedure declaration for C_FUNC
•
TAL_PARAM_PROC, a routine to be passed as a parameter to C_FUNC
•
TAL_CALLER, a routine that calls C_FUNC and passes TAL_PARAM_PROC as a 
parameter










