The following example illustrates that a called C function receives arguments in the order in which they were passed in a COBOL CALL statement.
The file MyFun.c contains the following source code, which calls the COBOL program tprog1:
#include <stdio.h>
extern void TPROG1(double *);
void
MyFun(short *ps1, short s2, long *k1, long *k2, double *m)
{
double x;
x = 2.0*(*m);
printf("MyFun got s1=%d s2=%d k1=%d k2=%d x=%f\n",
*ps1, s2, *k1,*k2, x);
}
long
MyFunR(short s1)
{
return(s1 * s1);
}
double
MyFunD(double d1)
{
double z;
/* calling COBOL */
z = 1122.3344;
(void) TPROG1(&z);
/* returning a value to COBOL */
return(2.0 * d1);
}
void
MyFunV(long *pn)
{
printf("MyFunV got %d %d %d\n", *pn, *(pn+1), *(pn+2));
}
MyFun.c consists of the following functions: