C/C++ Programmer's Guide (G06.27+, H06.08+, J06.03+)
#define _status_eq(x) ((x) == 0)
#define _status_ge(x) ((x) >= 0)
#define _status_gt(x) ((x) > 0)
#define _status_ne(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 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 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.
• If the pTAL definition specifies the EXTENSIBLE attribute, the interface declaration must specify
_extensible.
• If the pTAL 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 declaring
an external routine (in this case, for the CRE_ASSIGN_MAXORDINAL_ procedure). The
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)
The example above is equivalent to this interface declaration:
_extensible _tal _alias (“CRE_ASSIGN_MAXORDINAL_”)
get_max_assign_msg_ordinal (void);
2. This example, taken from the cextdecs header, shows the interface declaration for the
CHANGELIST system procedure. Notice that identifier names in the parameter type list are
optional, because C cares only about the types of the parameters:
_tal _variable _cc_status CHANGELIST(short, short, short);
3. This example shows you how to use the _cc_status type specifier while also using a function
prototype and a FUNCTION pragma to declare an external procedure.
Notice that the variable c_code is declared as type _cc_status so that it can be compared
against the condition code that is contained in the _status_eq() macro:
#include <tal.h> /* defines _cc_status and _status_eq */
_cc_status C_GETPOOL (short *pool_head,
long block_size,
long* block_addr);
124 Mixed-Language Programming for TNS/R and TNS/E Native Programs