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

is unknown. If no language attribute specifier is provided, the external procedure is assumed to
be written in the same language as the compilation.
After providing an interface declaration, your C or 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 interface declaration enables you to declare COBOL procedures and most types of pTAL
procedures, including:
pTAL procedures defined with the VARIABLE or EXTENSIBLE attribute
Procedures whose names are not valid C identifiers
pTAL procedures that do not return a value but do return a condition code
However, your C or C++ program cannot directly call a pTAL procedure that returns both a value
and a condition code. The subsection pTAL Procedures That You Cannot Call Directly (page 129)
presents techniques that enable your C or C++ program to access pTAL procedures that fall into
this category.
Using a Function Prototype and a FUNCTION Pragma
The recommended method for declaring an external routine is to use a standard function prototype
followed later by a FUNCTION pragma.
For more details on syntax, see FUNCTION (page 195) and for illustrations of FUNCTION pragmas
used in interface declarations, see Examples (page 124).
Using an Interface Declaration
The traditional method for declaring external routines is to use an interface declaration in which
you declare the procedure as if it were a C function, except that you include:
A language attribute specifier (_cobol, _tal or _unspecified) to identify the language
of the external procedure. For native C and C++, _tal denotes the pTAL language on both
TNS/R and TNS/E systems.
An _alias attribute specifier to assign the external name, or rather the name as known to
the other language.
The syntax for these older-style interface declarations is described in Attribute Specifier (page 55).
However, it is recommended that you use the FUNCTION pragma to declare 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 (page 126) 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 six macros
to interrogate the results of the procedure declared with the _cc_status type specifier:
#define _status_lt(x) ((x) < 0)
#define _status_le(x) ((x) <= 0)
Declaring External Routines 123