Declaring C to COBOL ILC

No special linkage declaration is required for ILC between C and Enterprise COBOL for z/OS, COBOL for OS/390 & VM, or COBOL for MVS & VM. However, for COBOL/370 and VS COBOL II, a C #pragma linkage directive is required for both static and dynamic calls. The C #pragma linkage directive can still be used with Enterprise COBOL for z/OS, COBOL for OS/390 & VM, and COBOL for MVS & VM, but it is no longer required, as these levels of the COBOL products support direct use of C-style linkage conventions via language constructs such as BY VALUE arguments and function RETURNING values. Further, with the support of DLL linkage conventions in the Enterprise COBOL for z/OS and COBOL for OS/390 & VM products, COBOL applications may directly interoperate with reentrant C modules that are linked as DLLs.

When a #pragma linkage directive is required, all entry declarations are made in the C code, both in the case where C calls COBOL and vice versa. The C #pragma linkage directive lets the C compiler generate parameter lists for COBOL or accept them from COBOL. It also ensures that writable static pointers are passed correctly for reentrant C modules and, for calls from pre-Language Environment-conforming COBOL, verifies that Language Environment has been properly established.

The #pragma linkage directive has the following format:

#pragma linkage(function_name, COBOL)

function_name can be up to eight characters (Enterprise COBOL for z/OS, COBOL for OS/390 & VM, and COBOL for MVS & VM allow 160 characters). function_name is either the COBOL program being called by C, or the C routine being called by COBOL.

Note: When declaring without #pragma linkage the reference to COBOL is for Enterprise COBOL for z/OS, COBOL for OS/390 & VM, and COBOL for MVS & VM. When declaring with #pragma linkage the reference to COBOL is for Enterprise COBOL for z/OS, COBOL for OS/390 & VM, COBOL for MVS & VM, COBOL/370, and VS COBOL II.