z/OS Language Environment Writing Interlanguage Communication Applications
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Determining the main routine

z/OS Language Environment Writing Interlanguage Communication Applications
SA38-0684-00

In Language Environment, only one routine can be the main routine; no other routine in the enclave can use syntax that indicates it is main. If you write the main routine in C, you must use language syntax to identify the routine as the main routine. If you use COBOL as the first program in the enclave that is to gain control, the program is effectively designated main by being the first to run.

In C, the same routine can serve as both the main routine and subroutines if recursively called. In such a case, the new invocation of the routine is not considered a second main routine within the enclave, but a subroutine. With a VS COBOL II or COBOL/370 single enclave, a recursively called main program is not permitted; Enterprise COBOL for z/OS, COBOL for OS/390 & VM and COBOL for MVS & VM support recursion.

Table 1 describes how C and COBOL identify the main routine.

Table 1. How C and COBOL main routines are determined
Language When determined Explanation
C Compilation Determined in the C source file by declaring a C function named main. The same routine can be used both as a main and subroutine if it is recursively called.
COBOL Run time Determined dynamically. If it is the first program to run, it is a main program. COBOL for MVS & VM, COBOL for OS/390 & VM, and Enterprise COBOL for z/OS support recursion, but the main program cannot be called recursively within a single enclave in VS COBOL II or COBOL/370.

An entry point is defined for each supported HLL. Table 2 identifies the desired entry point. The table assumes that your code was compiled using the Language Environment-conforming compilers.

Table 2. Determining the entry point
HLL Main entry point Fetched or dynamically called entry point
C CEESTART CEESTART or routine name if #pragma linkage(,fetchable) is used. In all other cases, the routine name.
COBOL Name of the first object program to get control in the object module Program name
Note: Specify ENTRY statement on link for the function name when not going through prelinker. Use #pragma map to remap a name and use the remapped name on ENTRY statement when prelinking.

C and COBOL routines that make up an ILC application are executed together in a single run unit (the equivalent of a Language Environment enclave). However, unlike in earlier versions of COBOL (VS COBOL II and OS/VS COBOL), the first COBOL program in a run unit is no longer necessarily considered the main program. If the first COBOL program is not the first program in the enclave to run, it is considered a subroutine in the Language Environment enclave.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014