Passing by value (indirect)

Data cannot be passed from C to COBOL; however, data can be passed by value (indirect) from COBOL to C. In this case, the variable is passed as a BY CONTENT argument and received by C as a pointer to the given type. For example, if a C function called FROMCOB is to receive a parameter passed by value (indirect) of type int, the function prototype declaration would look like this:
void FROMCOB(int *)

The C function must dereference the pointer to access the actual value. If the value of the pointer is modified by the C function, as opposed to modifying the value that the pointer points to, the results on return to COBOL are unpredictable. Thus, passing values by value (indirect) from COBOL to C should be used with caution, and only in cases where the exact behavior of the C function is known.

Table 1 shows the supported data types for passing by value (direct) and Table 1 shows the supported data types for passing by value (indirect).