Kinds of Linkage used by C or C++ Interlanguage Programs
Table 1 describes the kinds of linkage used by C++ interlanguage programs.
What calls or is called by a C or C++ program | Linkage used | Description of linkage | C++ Example |
---|---|---|---|
GDDM, ISPF, or non-Language Environment® conforming assembler | OS | Basic linkage defined by the operating system. OS Linkage allows integer, pointer, and floating point return types. Use of OS linkage with assembler is detailed in Specifying linkage for C or C++ to Assembler. | extern "OS" { … } |
Language Environment conforming assembler, NOXPLINK-compiled C or C++ declared with OS linkage (or C linkage, passing each parameter as a pointer) is to be called from XPLINK-compiled C or C++. Cannot be used on a function definition in XPLINK-compiled code. | OS_UPSTACK | This is the same as OS linkage in NOXPLINK-compiled programs. It is declared this way by the caller when the caller is XPLINK-compiled. The compiler will call glue code to transition from the XPLINK caller to the non-XPLINK callee. Also, see the OSCALL suboption of the XPLINK | NOXPLINK option in z/OS XL C/C++ User's Guide. | extern "OS_UPSTACK" { … } |
Assembler that does not follow Language Environment conventions. | OS_NOSTACK, OS31_NOSTACK | The compiler does not generate any glue code for this call. It provides the called program with a 72-byte save area pointed to by Register 13, as does OS_UPSTACK, but the save area may not be initialized. In particular, the Language Environment Next Available Byte (NAB) field may not be present. On entry to the called function, Register 15 contains the entry point address and Register 14 contains the return address. Register 1 points to an OS-style argument list. Typically a program would declare an operating system or subsystem assembler routine with this linkage, where such a routine was not Language Environment enabled. | extern "OS31_NOSTACK" { … } |
XPLINK-compiled C or C++ using OS_DOWNSTACK linkage, or XPLINK-enabled assembler. | OS_DOWNSTACK | As with OS linkage in NOXPLINK-compiled C or C++, the parameters are passed by reference rather than by value. However, parameter and stack management use XPLINK conventions. Also, see the OSCALL suboption of the XPLINK | NOXPLINK option in z/OS XL C/C++ User's Guide. | extern "OS_DOWNSTACK" { … } |
The following programs, using by-reference parameter passing:
|
REFERENCE | This is the same as OS_DOWNSTACK linkage in XPLINK-compiled programs and OS_UPSTACK in NOXPLINK-compiled programs. Use this for Language Environment-conforming assembler linkage. | extern "REFERENCE" { … } |
PL/I | PLI | Modification of OS linkage. It forces the compiler to read
and write parameter lists using PL/I linkage conventions. This linkage
type extends OS linkage by allowing structures as return types. (When
the return type is a structure, the caller allocates a buffer large
enough to receive the returned structure and passes it, by reference,
as a hidden final argument.)
This linkage type is maintained for compatibility with PL/I products prior to the Enterprise PL/I for z/OS® product. With newer PL/I products use the C linkage type instead. |
extern "PLI" { … } |
COBOL | COBOL | Forces the compiler to read and write parameter lists using
COBOL linkage conventions. All calls from C++ to COBOL must be void functions.
This linkage type is maintained for compatibility with COBOL/370 and VS COBOL II. With newer COBOL products, you can call COBOL functions with the REFERENCE and OS linkage types, which allow integer return types. If the COBOL routine receives parameters by value (a pragmaless call), you can use the C linkage type. |
extern "COBOL" { … } |
FORTRAN | FORTRAN | Forces the compiler to read and write parameter lists using FORTRAN linkage conventions. | extern "FORTRAN" { … } |
C | C | Use in C++ to force the compiler to read and write parameter
lists using C linkage conventions. C code and the Data Window Services
(DWS) product both use C linkage.
With XPLINK, C and C++ use the same linkage conventions. When this linkage is specified in C++ code, the specified function is known by its function name alone rather than its name and argument types. It cannot be overloaded. |
extern "C" { … } |