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-11
Calling TAL Routines From TNS C Modules
Calling TAL Routines From TNS C Modules
A TNS C module has full access to the TNS C run-time library even if the C module
does not contain the main() routine.
When you code TNS C modules that call TAL routines:
•
Include an interface declaration for each TAL routine to be called, or a function
prototype and a FUNCTION pragma, as described in Using a Function Prototype
and a FUNCTION Pragma on page 8-3.
•
If a called TAL routine sets the condition code, include the talh header file.
•
If a called routine is a system procedure, include the cextdecs header file.
In C, interface declarations are comparable to EXTERNAL procedure declarations in
TAL.
To specify an interface declaration in C, include:
•
The keyword _tal
•
The _variable or _extensible attribute, if any, of the TAL routine
•
The data type of the return value, if any, of the TAL routine
•
A routine identifier
•
A public name if the TAL identifier is not a valid C identifier
•
A parameter-type list or, if no parameters, the keyword void
•
For extended pointers in the parameter-type list, the keyword _far after the
parameter type
The return type value can be any of the following:
For information on calling TAL routines that both return a value and set a condition
code (CC), see TAL Procedures That You Cannot Directly Call on page 7-12.
Here are examples of interface declarations for calling TAL routines:
_tal _variable short SEGMENT_ALLOCATE_ (short, long,
short *, short);
_tal _variable _cc_status SEGMENT_DEALLOCATE_ (short, short);
Return Type Value Meaning
void The TAL routine does not return a value.
fundamental-type The TAL routine returns a value. Specify one of, or a pointer to
one of, the character, integer, or floating-point types.
_cc_status The TAL routine does not return a value but does set a condition
code. The tal.h header file contains three macros that
interrogate this condition code: _status_lt(x),
_status_eg(x), and _status_gt(x).