cdecl keyword
Greg Limes
limes at sun.uucp
Tue Apr 26 03:12:26 AEST 1988
In article <4737 at cup.portal.com> Glenn_A_Story at cup.portal.com writes:
>Wait a minute! What's the difference between "the address of 'x' passed
>by value" and "'x' passed by reference"?
It all depends on what the caller is expecting. In the first, the
caller is expecting an address, and is free to muck about with the
formal parameter holding it; this is the convention used by C. In the
second, the function is expecting something of the same type as 'x',
and if this value is changed, the value of 'x' in the caller (who is
passing 'x') is changed. If I remember correctly, this convention is
used in FORTRAN and Pascal.
Thus, if I have a library function written in FORTRAN that expects an
integer, my calling function written in C must call that function with
a pointer to an integer; likewise, if I write a C function that will be
called by a FORTRAN program, then if FORTRAN passes an integer, C must
expect a pointer to an integer.
--
Greg Limes [limes at sun.com] frames to /dev/fb
More information about the Comp.lang.c
mailing list