The conventions for passing parameters, and other details of the interface between the two programs.
COBOL programs can call and be called by programs written in other languages. However, some languages handle calls differently
from COBOL. For example, some language pass parameters in the opposite order from that expected by COBOL programs. To enable
COBOL and non-COBOL programs to call each other, you can adjust the calling mechanisms that the COBOL program uses or that
it expects to be used.
To specify the calling mechanisms you require, you first construct the call convention number that produces the required mechanisms.
The call convention number is a 16-bit number defined as follows:
- Bit 0
-
0 |
Process parameters from right-to-left |
1 |
Process parameters from left-to-right |
Note: This bit is ignored in JVM COBOL.
- Bit 1
-
0 |
Parameters removed from stack by calling program |
1 |
Parameters removed from stack by called program |
Note: This bit is ignored in JVM COBOL.
- Bit 2
-
0 |
RETURN-CODE is updated on exit |
1 |
RETURN-CODE is not updated on exit |
Any RETURNING phrase is not affected by this bit
- Bit 3
-
0 |
Normal linking behavior |
1 |
Call is resolved at link time |
- Bits 4 and 5
- Reserved (always 0).
- Bit 6
-
0 |
The call does not conform to the Windows stdcall calling convention |
1 |
The call conforms to the Windows stdcall calling convention |
This has no effect on dynamic calls.
Note: In JVM COBOL this bit is only supported on Windows.
- Bit 7
- Reserved (always 0).
- Bit 8
-
0 |
The parameter-count of individual entry-points is checked |
1 |
The parameter-count of individual entry-points is not checked |
Note: This bit is ignored in JVM COBOL.
- Bit 9
-
0 |
The case of the program or call name is disregarded |
1 |
The case of the program or call name is significant |
This call convention is an instruction to the generator on how to treat the text of a quoted program name or call name when
litlinking. If this bit is 0 the case of the program or call name might still be significant depending on the CASE generator
directive.
Note: This bit is ignored in JVM COBOL.
- Bit 10
-
0 |
Normal calling behavior |
1 |
The first parameter is always the RETURNING item for the CALL |
- Bits 11-15
- Reserved (always 0).
When you have constructed the call convention number, you convert it to a decimal number, and then assign this decimal number
to a name, by defining it the Special Names paragraph. You then use the call convention name in the CALL statement.
For example, if you define the following call conventions:
SPECIAL-NAMES.
CALL-CONVENTION 0 IS Microsoft-c
CALL-CONVENTION 3 IS Pascal.
you can then use one convention when calling a C program as follows:
CALL Microsoft-c "routine-name" USING parameter-1,parameter-2
and use the other convention when receiving a call from a Pascal program, such as:
PROCEDURE DIVISION Pascal USING parameter-1,parameter-2
If you do not specify a call convention, the standard COBOL convention (call-convention 0) is assumed, unless the DEFAULTCALLS
Compiler directive is used.