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-4
Declaring External Routines
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 (-), you must use the
_alias attribute in the interface declaration.
To create a C function name that resembles the pTAL procedure name, you can
substitute an underscore (_) for every occurrence of the circumflex or hyphen in
the pTAL name.
Return value types
For procedures that return a scalar value, you should declare the C counterpart to
the pTAL scalar type as the procedure type in the interface declaration. Compatible
pTAL and C Data Types on page 8-7 shows the C counterparts to pTAL 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
contains three macros to interrogate the results of the procedure declared with the
_cc_status type specifier:
#define _status_lt(x) ((x) < 0)
#define _status_eg(x) ((x) == 0)
#define _status_gt(x) ((x) > 0)
Before you can use these macros, you must include the tal.h header.
Note that you should avoid designing pTAL procedures that return a condition code
because that is an outdated programming practice. Guardian system procedures
must retain this interface for reasons of compatibility.
Parameter types
When creating an interface declaration for a non-C procedure, you must ensure
that the declared C type of a parameter matches the defined type of that
parameter. The C compiler cannot perform this task automatically, because it does
not have direct access to each language’s definition. The C compiler does,
however, check that the type of an argument in a call to a non-C procedure
matches its corresponding parameters type. Ensuring that the C and non-C types
of a scalar parameter match is a simple task because most scalar types have
direct counterparts in C, as shown in Appendix D, Data Type Correspondence.
When you invoke a COBOL procedure, COBOL always returns void because the
COBOL language has no way to declare a COBOL program to be a function.
Therefore, you must always specify COBOL routines with type void.
Native COBOL programs use 32-bit addressing for all data items in the Extended-
Storage Section and all data items in the Linkage Section that are not described as
having ACCESS MODE of STANDARD.