Xref: utzoo comp.lang.c:9622 comp.sys.ibm.pc:14848 Path: utzoo!mnetor!uunet!husc6!mailrus!ames!oliveb!sun!limes From: limes@sun.uucp (Greg Limes) Newsgroups: comp.lang.c,comp.sys.ibm.pc Subject: Re: cdecl keyword Message-ID: <50731@sun.uucp> Date: 25 Apr 88 17:12:26 GMT References: <1238@wjvax.UUCP> <297@ho7cad.ATT.COM> <1242@wjvax.UUCP> <3867@super.upenn.edu> <185@premise.ZONE1.COM> <1443@bigtex.uucp> <4737@cup.portal.com> Reply-To: limes@sun.UUCP (Greg Limes) Organization: Sun Microsystems, Mountain View Lines: 19 In article <4737@cup.portal.com> Glenn_A_Story@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@sun.com] frames to /dev/fb