Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!pacbell.com!att!ucbvax!PAN.SSEC.HONEYWELL.COM!thompson From: thompson@PAN.SSEC.HONEYWELL.COM (John Thompson) Newsgroups: comp.sys.apollo Subject: re: function prototype mystery? Message-ID: <9104121527.AA29494@pan.ssec.honeywell.com> Date: 12 Apr 91 15:27:37 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 51 <> > I don't understand the argument declarations used > in the following function prototype. Could someone > give me a clue? I tried RTFM, with no luck. RTF C-Manual, section 3.16 (Reference Variables - Domain Extension) > I'm using the apollo system call proc2_$get_info(), > which is defined in proc2.h as: > > void proc2_$get_info( > uid_$t &p2_uid, > proc2_$info_t *info, > pinteger &info_buf_len, /* size of info buffer (bytes) */ > status_$t *sts > ); > > What do the &'s do to the first and third arguments? > It looks to me like the function expects addresses, but if > I pass addresses to it, the compiler (cc 6.7.m, OS10.3) complains > that the argument type conflicts with the declaration. A reference variable (from C++) (as I understand it) is basically a "pass in the most convenient manner, but make sure that it's local" (equiv to 'IN' in Domain Pascal). This allows the compiler to pass large structures by pointer without passing them as modifiable arguments. I assume that the compiler also handles making a local copy for the receiving procedure. What this means for you as a programmer is that, when you see an '&' in a prototype declaration, you should be passing an object, and not a pointer to an object. The compiler will decide whether to actually pass the pointer, but if it does, it makes sure that the procedure treats it (gets it?) as a local structure, and not as a pointer to your object. > What works is something like proc2_$get_info(p2_uid,&info,bufferlength,&status). Why? Is this some kind of apollo-ism, or something ANSI-like? Well, it's a 'Domain Extension', so it's definitely Apollo-ism. I believe it conforms to C++'s standard, so maybe it'll become standard? (Ha!) BTW: When we (another engineer) encountered problems in DDE with looking at reference variables, HP/Apollo said that "well, that's an extension and you really shouldn't be using it in the first place" -- even though the manual states that "reference variables provide a clean syntax for passing arguments by reference." Yet another case of HP (sorry guys, but I blame you) screwing the Apollo customers. -- jt -- John Thompson Honeywell, SSEC Plymouth, MN 55441 thompson@pan.ssec.honeywell.com Me? Represent Honeywell? You've GOT to be kidding!!!