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

Table Of Contents
Mixed-Language Programming for TNS Programs
HP C/C++ Programmer’s Guide for NonStop Systems429301-010
7-4
Writing Interface Declarations
A language attribute specifier (_c, _cobol, _fortran, _pascal, _tal, or
_unspecified) to identify the language of the external procedure.
An _alias attribute specifier to assign the external name, or rather the name as
known to other language.
The syntax for these older-style interface declarations is described under Attribute
Specifier on page 2-10. You should use the FUNCTION pragma to declare external
routines.
After providing an interface declaration, your TNS C program uses normal function
calls to access the procedure written in the other language. However, remember that
these calls cross language boundaries; therefore, there are restrictions beyond those
of normal C function calls.
The C interface declaration enables you to declare most types of COBOL, FORTRAN,
Pascal, and TAL procedures, including:
D-series Pascal and TAL procedures defined with the VARIABLE or EXTENSIBLE
attribute
Procedures whose names are not valid C identifiers
TAL procedures that do not return a value but return a condition code
COBOL, FORTRAN, D-series Pascal, and TAL procedures with extended pointer
(.EXT) parameters
However, your TNS C program cannot directly call a TAL procedure that both returns a
value and returns a condition code. For a description of techniques that enable your
TNS C program to access TAL procedures that fall into this category, see TAL
Procedures That You Cannot Directly Call on page 7-12.
Usage Guidelines
Procedure names
When you specify the C name of a non-C procedure, you should use the non-C
name of the procedure if it is a valid C identifier. If the name is not a valid
C identifier because it includes circumflexes (^) or hyphens (-), simply substitute
underscores (_) for the circumflexes and hyphens in the C name.
Return value types
For procedures that return a scalar value, you should declare the C counterpart to
the TAL scalar type as the procedure type in the interface declaration. Compatible
TAL and TNS C Data Types on page 7-8 shows the C counterparts to TAL scalar
types.
For procedures that return a condition code, you should declare _cc_status as
the procedure’s return type in the interface declaration. The tal.h header file