Supported data types passed by value (direct) between C and COBOL

Table 1 identifies the data types that can be passed by value (direct) as parameters between C and COBOL applications.

Table 1. Supported data types passed by value (direct) without #pragma
C COBOL (by value)
char PIC X, PIC A
signed short int PIC S9(4) USAGE IS BINARY
unsigned short int PIC 9(4) USAGE IS BINARY
signed int, signed long int PIC S9(9) USAGE IS BINARY
unsigned int PIC 9(9) USAGE IS BINARY, LENGTH OF
unsigned long int PIC 9(9) USAGE IS BINARY
float COMP-1
double COMP-2
pointer to... POINTER, ADDRESS OF

If the COBOL program receives int parameters from the C calling function that might have a value that is larger than that declared as the maximum size by the COBOL picture clause, the COBOL program must either be compiled with the TRUNC(BIN) compiler option or each binary data item that receives int parameters from C must be declared as USAGE IS COMP-5. Taking these actions will guarantee that truncation of high-order digits does not occur. For more information about the TRUNC(BIN) compiler option or about using COMP-5 data items, see the appropriate version of the programming guide in the Enterprise COBOL for z/OS library.