On 11/6/2011 1:10 PM, Bernd Oppolzer wrote:
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
<ad>
We discuss all these issues, and more, in our 3 day course
"Cross Program Communication in z/OS". Details at:
http://www.trainersfriend.com/Language_Environment_courses/m520descr.htm
The course covers any mix of these languages that the students want
to include: Assembler, COBOL, PL/I, and C. Lectures are set and
labs available for all four languages, and you can focus on just
one language or any mix you like.
</ad>
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 [email protected] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html
--
Kind regards,
-Steve Comstock
The Trainer's Friend, Inc.
303-393-8716
http://www.trainersfriend.com
* To get a good Return on your Investment, first make an investment!
+ Training your people is an excellent investment
* Try our new tool for calculating your Return On Investment
for training dollars at
http://www.trainersfriend.com/ROI/roi.html
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html