First, IBM's C is in no way different from other's C.
Then: C passes EVERY parameters as values, that is:
if you pass integers (BIN FIXED(31)) to a subroutine, normally PL/1 -
and FORTRAN etc. -
pass the address of the integer, but C passed the value of the integer -
that is, Reg 1
points to the address of the argument in all other languages, but to the
value in C.
(you can do this in newer PL/1, too, by specifying BYVALUE on the
procedure definition)
Now, if you want your C function to be compatible with the PL/1 caller,
you have to
specify explicitly that the C function gets pointers, where in PL/1 you
don't.
For example:
CALL CFUNC (I1, I2);
I1 and I2 defined as BIN FIXED(31) in PL/1
the function CFUNC in C must be defined as
void cfunc (int *i1, int *i2);
When passing structures, there are more problems, because PL/1 normally
passes descriptor/locator
pairs, and not only addresses of structures. Our solution is, that we
"convince" PL/1 not to do this,
but to pass only addresses of structures to the called procedure. This
is an old technique which goes
back to 1980, when we integrated PL/1 into the existing ASSEMBLER
environment. So this fitted well,
when we added C in 1992.
Kind regards
Bernd
Am 29.06.2013 16:29, schrieb Paul Gilmartin:
On Sat, 29 Jun 2013 15:28:06 +0200, Bernd Oppolzer wrote:
normally pointers to structures are passed between PL/1 and C,
and these structures are defined (language independent) using a
repository, from which both structure definitions for both languages
are generated (and for ASSEMBLER, too, BTW).
One thing I believe I've noticed about IBM's C is that parameters of
most types are passed by reference: the address of the parameter,
not its value, is passed in the argument list. It's left to the subroutine
to make a copy of the value. However, if the parameter is of a pointer
type, its value, not its address is passed in the argument list.
Confusing. And could produce unexpected results if the programmer
resorts to type punning.
Did I observe correctly?
-- gil
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN