When calling C routines from other languages like COBOL or PL/1 (or
FORTRAN),
you have to take into account that in C the parameters are passed "by
value", whereas
the other languages pass them "by reference", that is, addresses of the
variables.
The solution is simple: to construct your C routines so that they can be
called from
other languages, put a star on every parameter, so that C expects
pointers instead
of values. Of course, when accessing the parameters inside the C functions,
you have to specify the stars, too.
that is:
int cfunc (int *x, double *x, struct type *p, ..);
Furthermore, the result type should be int, so that other languages can
read the
return code from the C function result.
If the parameter type is pointer, you need two stars, of course (that
was your point).
Of course, this does not solve all the problems. You have still the
issue with char strings,
which are in fact vectors of single chars, so there is already a star.
And you need to
unterstand that when passing vectors as parameter, you normally pass the
starting address.
And, with languages like PL/1, you have the locator/descriptor problem.
But that's
another topic and has nothing to do with C.
Kind regards
Bernd
Am 06.11.2011 20:08, schrieb Gibney, Dave:
With the assistance of several folks over on MVS-OE, I solved my
problem. It is clear here that I did fail in the original question to
be clear enough that my driving program is not C. The whole intent was
to be able to pass that address from ldap_init back out to the non C
driver so that it could be reused by the thousands of calls. The
solution was: extern int ret2nat (int *back_value, LDAP **ld, char
*msg) This pointer to a pointer format allows the fullword in the
calling non C program hold the LDAP handle from call to call.
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@bama.ua.edu with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html