Mixing languages in Language Environment

You can use Language Environment® to build an application that is composed of programs that are written in different high-level source languages and assembler language.

Assembler language subroutines called from a high level language (HLL) program are fairly straightforward and common. A subroutine that is called from one HLL, but written in another, needs much more careful consideration and involves interlanguage communication (ILC). Language Environment defines an ILC application as one that is built from two or more HLLs and, optionally, assembler language. For more information, see z/OS Language Environment Writing Interlanguage Communication Applications.

In Language Environment, if there is any ILC in a run unit under CICS®, each compile unit must be compiled with a Language Environment-conforming compiler. CICS supports the following HLLs:
  • C/C++
  • COBOL
  • PL/I
The following sections describe the conditions for each pair of HLLs. If your application contains only two HLLs, consult the appropriate section. If your application contains all three HLLs, consult the sections that correspond to each interface in your application.

C/C++ and COBOL

The conditions under which Language Environment supports ILC between routines written in C/C++ and COBOL depend on the following factors:
  • Whether the language is C or C++.
  • Which COBOL compiler is used and whether DLL is specified as a compiler option.
  • Whether the call is static or dynamic.
  • Whether the function that is invoked is in the module, or exported from a DLL.
  • Whether the program is reentrant.
  • What, if any, #pragma linkage statement is in your C program.
  • Whether your C program exports functions or variables.
  • What, if any, extern statement is in your C++ program.

For information about the effect of these factors, see z/OS Language Environment Writing Interlanguage Communication Applications.

C/C++ and PL/I

Under CICS, if all the components of your C/C++ and PL/I application are reentrant, Language Environment supports ILC between routines compiled by C/C++ and PL/I as follows:
  • C/C++ routines can statically call PL/I routines and PL/I routines can statically call C/C++ routines.
  • C/C++ routines can fetch() PL/I routines that have OPTIONS(FETCHABLE) specified. If the called routine contains any CICS commands, C/C++ must pass the EIB and the COMMAREA as the first two parameters on the call statement.
  • PL/I routines can FETCH only those C/C++ routines that were not processed by the CICS translator. This is because during the dynamic call, certain static fields created by the translator cannot be set correctly.

COBOL and PL/I

Under CICS, Language Environment supports ILC between routines compiled with Language Environment-supported COBOL and PL/I Compilers, as follows:
  • COBOL routines can statically call PL/I routines, and PL/I routines can statically call COBOL routines.
  • COBOL programs can dynamically call PL/I routines that have OPTIONS(FETCHABLE) specified, and PL/I routines can FETCH COBOL programs.

If the called routine contains any CICS commands, the calling routine must pass the EIB and the COMMAREA as the first two parameters on the CALL statement.

Assembler language

  • You can make static or dynamic calls from any Language Environment-conforming HLL program to a Language Environment-conforming assembler language subroutine. Conversely, a Language Environment-conforming assembler language routine can make a static call to any Language Environment-conforming routine, and can dynamically load another routine, either assembler language or HLL, by using either of the Language Environment macros CEEFETCH or CEELOAD.
  • You cannot delete (release) an ILC module that was loaded by using CEELOAD.
  • You can use the CEERELES macro to release an ILC module that was fetched by using CEEFETCH.
  • Use the language that fetched it to delete an assembler language routine. This can be done from C/C++, COBOL, and PL/I, only if there is no ILC with PL/I in the module being released.

Additionally, you can make static calls from any Language Environment-conforming HLL program or assembler language subroutine to a non-conforming assembler language subroutine. However, a non-conforming assembler language routine cannot make a static call to any Language Environment-conforming routine, and cannot fetch or load a conforming routine, because it cannot use the Language Environment macros.

For assembler language to call C or C++, you must include the following statement:
C
#pragma linkage(,OS)
C++
extern "OS"

DL/I

If you use DL/I in your ILC application under CICS, calls to DL/I, either by an EXEC DLI statement or by a CALL xxxTDLI, can be made only in programs with the same language as the main program.

Language Environment does not support CALL CEETDLI under CICS.