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-9
Considerations When Interfacing to pTAL
C Routines That You Cannot Call Directly
pTAL procedures cannot call a C routine that:
•
Passes a struct or union parameter by value
•
Returns a struct or union parameter by value
•
Uses C-style variable argument list (...)
Calling pTAL Routines From C Modules
A C module has full access to the C run-time library even if the C module does not
contain the main() routine, but the C module might need to explicitly initialize the C
run time library.
When you code C modules that call pTAL routines:
•
Include an interface declaration or a function prototype and FUNCTION pragma for
each pTAL routine to be called.
•
If a called pTAL routine sets the condition code, include the talh header file.
•
If a called routine is a system procedure, include the cextdecs header file.
It is recommended that you declare an external routine by using a function prototype
and FUNCTION pragma instead of an interface declaration (for more information, see
Using a Function Prototype and a FUNCTION Pragma on page 8-3). In C, an interface
declaration is comparable to an EXTERNAL procedure declaration in pTAL (for more
information, see Using an Interface Declaration on page 8-3).
Specifying a FUNCTION Pragma
To declare an external routine by using a function prototype and a FUNCTION pragma,
include the following:
•
The keyword _tal
•
The variable or extensible attribute, if any, of the pTAL routine
•
A public name if the pTAL identifier is not a valid C identifier
Specifying an Interface Declaration
To declare an external routine by using an interface declaration, include the following:
•
The keyword _tal
•
The variable or extensible attribute, if any, of the pTAL routine
•
The data type of the return value, if any, of the pTAL routine
•
An identifier for the pTAL routine
•
A public name if the pTAL identifier is not a valid C identifier
•
A parameter-type list or, if no parameters, the keyword void
The return type value can be any of the following: