Deciding which type of pointer to use

Use procedure pointers to call other COBOL programs and to call Language Environment® callable services. Use function pointers to communicate with C/C++ programs or with services provided by the Java™ Native Interface.

About this task

Procedure pointers are more efficient than function pointers for COBOL-to-COBOL calls, and are required for calls to Language Environment condition-handling services.

Many callable services written in C return function pointers. You can call such a C function pointer from your COBOL program by using COBOL function pointers as shown below.


 IDENTIFICATION DIVISION.
 PROGRAM-ID. DEMO.
 ENVIRONMENT DIVISION.
 DATA DIVISION.
*
 WORKING-STORAGE SECTION.
 01 FP USAGE FUNCTION-POINTER.
*
 PROCEDURE DIVISION.
     CALL "c-function" RETURNING FP.
     CALL FP.