On 6/29/2013 8:29 AM, Paul Gilmartin wrote:
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

Not entirely.

First, though, I'd like to question your assumption that
if the address of a parameter is passed the subroutine
will make a copy of the value. If an address is passed I
would expect the subroutine to tie the address to a
DSECT / based / linkage section (Assembler / PL/I / COBOL)
structure, thus referencing the data without making a copy.

Passing arguments in C:

* Of course, there is interaction based on the prototype
  of the function declaration and how an argument is
  specified on the function call, but generally ...

* If you pass the name of a structure, the entire
  structure is passed in the argument list

* If you pass the name of any item preceded by an apostrophe
  the address of the item is passed in the argument list

  (This is true for structures and arrays and elementary items)

* If you pass the name of a pointer preceded by an asterisk,
  the value pointed at by the pointer is placed into the
  argument list

* If you pass a character literal (e.g.: 'C'), the literal
  is placed into a full word in the argument list, right
  justified, left filled with nulls

* If you pass a numeric literal or numeric expression, the
  expression is converted to the format indicated in the
  prototype and placed into the argument list

  (of course, the literal or expression must be such that
   such a conversion is possible; otherwise you get a
   compile error)

* A variable number of arguments may be passed using an
  ellipsis (...) in the function prototype

* Note that C never turns on the end-of-list bit unless
  you include

  #pragma linkage(subroutine_name,OS)


"Cross Program Communication in z/OS" - 3 days

  http://www.trainersfriend.com/Language_Environment_courses/m520descr.htm


--

Kind regards,

-Steve Comstock
The Trainer's Friend, Inc.

303-355-2752
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 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 lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to