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-5
Examples
contains three macros to interrogate the results of the procedure declared with the
_cc_status type specifier:
#define _status_lt(x) ((x) == 2)
#define _status_eg(x) ((x) == 1)
#define _status_gt(x) ((x) == 0)
Before you can use these macros, you must include the tal.h header file.
Note that you should avoid designing TAL 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 TNS C compiler cannot perform this task automatically, because it
does not have direct access to each language’s definition. The TNS C compiler
does, however, check that the type of an argument in a call to a non-C procedure
matches its corresponding parameter’s 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 TNS 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 TNS COBOL routines with type
void.
•
TNS 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.
•
If the TAL or D-series Pascal definition specifies the EXTENSIBLE attribute, the
interface declaration must specify _extensible.
•
If the TAL or D-series Pascal definition specifies the VARIABLE attribute, the
interface declaration must specify _variable.
Examples
1. This example, taken from the stdlib.h header file, shows the preferred style for
an interface declaration (in this case, for the CRE_ASSIGN_MAXORDINAL_
procedure). The interface declaration consists of a standard function prototype and
a FUNCTION pragma:
void get_max_assign_msg_ordinal (void);
...
#pragma function get_max_assign_msg_ordinal \
(alias(“CRE_ASSIGN_MAXORDINAL_”), extensible, tal)