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

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)
The example is equivalent to this older-style interface declaration:
_extensible _tal _alias (CRE_ASSIGN_MAXORDINAL_) \
get_max_assign_msg_ordinal (void);
2. This example, taken from the cextdecs header file, shows the interface declaration for the
CHANGELIST system procedure. Notice that identifier names in the parameter type list are
optional because C only cares about the types of the parameters:
_tal _variable _cc_status CHANGELIST(short, short, short);
3. In this example, the parameter type must be followed by the _far specifier because the TAL
parameter was declared as an extended pointer using .EXT:
_tal _variable _cc_status PROC_3 (short _far *);
4. This example shows you how to use the _cc_status type specifier. Notice that the variable
c_code is declared as type short so that it can be compared against the condition code
that is contained in the _status_eq() macro:
_tal _cc_status _alias ("C^GETPOOL") C_GETPOOL
(short _far *pool_head,
long block_size,
long *block_addr);
short *pool_alloc(long size)
{
short c_code;
long blk_addr;
c_code = C_GETPOOL(my_pool,size,&blk_addr);
100 Mixed-Language Programming for TNS Programs