Data type semantics vary significantly in the programming languages that can be linked by means of ILCS. The data types that have the same data representation in the individual programming languages (and can therefore be passed as parameters without problems) are listed below. When other data types are used as parameters, a detailed knowledge of the type of data storage is required in order to ensure correct program execution.
The parameters are passed “by reference”, i.e. the address of the data item is passed.
Compiler | Data types | |||
Binary | Floating-point | Floating-point | String | |
C / C++ | long | float | double | char <var> [<size>] |
COBOL2000 | PIC S9(i) COMP-5 | COMP-1 | COMP-2 | USAGE DISPLAY |
Ada | INTEGER | ⎯ | FLOAT | EBCDIC_STRING |
ASSEMBH | F | E | D | C |
FOR1 | INTEGER*4 | REAL*4 | REAL*8 | CHARACTER*i |
Pascal-XT | long_integer | short_real | long_real | packed array |
PLI1 | BIN FIXED(31) | BIN FLOAT(21) | BIN FLOAT(53) | CHAR(i) |
RPG3 | binary item | ⎯ | ⎯ | alphanum. item, |
UX-Basic | %%,? | ! | !! | $ |
The calling program compiles a list of passed addresses. The number of parameters is passed in register 0, while the address of the list is passed in register 1 (see section “Register conventions”).
Parameter passing in Assembler
The data must always be aligned when stored, i.e. 32-bit integers represented in binary form are aligned on word boundaries, floating-point numbers are aligned on word or doubleword boundaries, and strings are aligned on byte boundaries. The length of strings is constant and is known to the called program.
Parameter passing in C and C++
In C/C++ parameters are passed “by value” as standard in compliance with language definition. This type of parameter passing is possible without restrictions only in program systems in which only C and C++ are involved.
If objects in other languages are linked, the following steps must be taken:
When the non-C or non-C++ routine is called, the address of the data element to be passed must be given in C/C++, for example &par. Technically speaking, the address of the data element is then passed “by value”.
If a C/C++ routine is called from a non-C/C++ routine, the formal parameters in C/C++ must be declared as pointers to the data elements to be passed, e.g. f (T *par).
Parameter passing in COBOL
In COBOL85 and COBOL2000, parameters are passed as standard “by reference” (see the table "Compatible data types for parameter passing").
Parameter passing “by value”
COBOL2000 can pass any numeric parameters “by value” if a prototype exists for the called program. If no prototype exists, parameter passing “by value” is only possible with restrictions (see next page).
The position and alignment of the data in the parameter list are dependent on the data description in the prototype. The following tables indicate the effects of the data descriptions:
Binary data | Representation in parameter list |
Halfword (1 <= i <= 4) | right-justified in aligned whole word (bytes 1 and 2 undefined) |
Whole word (5 <= i <= 9) | aligned whole word |
Doubleword (10 <=i <= 18) | aligned doubleword (bytes inserted for alignment are undefined) |
Floating point data | Representation in parameter list |
Word (USAGE COMP-1) | aligned whole word |
Doubleword (USAGE COMP-2) | aligned doubleword (bytes inserted for alignment are undefined) |
Numeric data that is packed (USAGE COMP-3/PACKED DECIMAL) or printable (USAGE DISPLAY) should only be passed between COBOL2000 programs “by value”. The data is stored in the parameter list flush left on word boundary (length <8 bytes) or doubleword boundary (length ≥ 8 bytes).
If no prototype exists, only data items with the following definitions can be passed “by value” with COBOL2000:
COMP-5 PIC[S]9(i) (1 <= i <= 9) or
1-byte data item of any type
If necessary, the parameter is expanded to 4 bytes by padding with binary zeros flush left.
This restricted parameter passing “by value” is also possible with COBOL85 Version 2.1B or later.
Passing OMITTED (only possible with COBOL2000)
Parameters that are omitted when a subroutine is called (specification of OMITTED in the call or OPTIONAL in the prototype) are stored as an aligned whole word with the value X’FFFFFFFF’ in the parameter list.
In an OMITTED test in a called COBOL2000 program, each parameter that appears in the parameter list with the address X’FFFFFFFF’ is evaluated as not passed (OMITTED).
Parameter passing in Java
Although it is possible to transfer data between C and Java programs, this cannot be done via the ILCS interface. For information on transferring data between C/C++ and Java please refer to your Java documentation.