ILE COBOL Programmer's Guide


Calling ILE C and VisualAge C++ Programs and Procedures

Note:
All references to ILE C in this section also apply to VisualAge C++.

An ILE COBOL program can call ILE C programs and procedures using dynamic program calls or static procedure calls.

When a dynamic program call is used to call an ILE C program, the ILE C program must be compiled and bound as a separate program object. When a static procedure call is used to call an ILE C procedure, the ILE C procedure must first be compiled into a module object and then bound to the calling ILE COBOL program. In ILE C, an ILE procedure corresponds to an ILE C function. Refer to the WebSphere Development Studio: ILE C/C++ Programmer's Guide for a description of compiling and binding ILE C programs and procedures.

You call an ILE C program or procedure from an ILE COBOL program by using the CALL literal statement (were literal is the name of the ILE C program or procedure). To call the ILE C program or procedure, you write the CALL literal statement in the same way as you would if you were calling another ILE COBOL subprogram. See Using Static Procedure Calls and Dynamic Program Calls for detailed information about how to write the CALL statement in your ILE COBOL program to call an ILE C program using dynamic program calls or static procedure calls.

You can also call an ILE C program from an ILE COBOL program by using the CALL identifier statement. See Using CALL identifier for more information on CALL identifier.

Alternately, you can use CALL procedure-pointer to call an ILE C program or procedure from an ILE COBOL program. See Using CALL procedure-pointer for more information on CALL procedure-pointer. A procedure-pointer in ILE COBOL is similar to a function pointer in ILE C. You can pass a procedure-pointer as a argument on the CALL statement from ILE COBOL to an ILE C function and have the ILE C function define its parameter as a function pointer.

You can only call an ILE C function that returns a value if the RETURNING phrase of the ILE COBOL CALL statement has been specified.

Two or more ILE C programs in the same activation group can interact with each other's runtime resources. Refer to the WebSphere Development Studio: ILE C/C++ Programmer's Guide for a description of how this is accomplished. Therefore, you should ensure that the ILE C programs you call from your ILE COBOL program are designed to work together in the same activation group. Two ILE C programs in the same activation group can share things like errno, signal vectors, and storage pools. If your ILE COBOL program needs to call more than one ILE C programs that are not designed to share the same run time then specify a different name for the activation group in which the ILE C program will run.

ILE C allows recursion but ILE COBOL does not for default program type. You need to use a RECURSIVE clause in PROGRAM-ID paragraph to make a COBOL program become a recursive program. If an ILE C function calls an ILE COBOL non recursive program recursively, a runtime error message will be generated from the ILE COBOL program.

To call an ILE C function from an ILE COBOL program, the name of the ILE C function being called may need to be case-sensitive, longer than 10 characters (up to 256 characters), and contain some special characters. In this case, use a static procedure call and compile your ILE COBOL program with the *NOMONOPRC value of the OPTION parameter of the CRTCBLMOD or CRTBNDCBL commands.

When a ILE C++ compiler procedure is called from ILE COBOL, the keywords extern "COBOL" or extern "C" should be placed on the ILE C++ compiler function prototype, to prevent the mangling of the ILE C++ compiler function name. Use extern "C" if ILE COBOL is passing BY VALUE arguments to ILE C++ compiler.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]