From: Nate Eldredge Newsgroups: comp.os.msdos.djgpp Subject: Re: HELP ! (returning structures) Date: Wed, 29 Sep 1999 16:44:40 -0700 Organization: Harvey Mudd College Lines: 25 Message-ID: <37F2A468.75644B8@hmc.edu> References: <7srkeu$3kh$1 AT tron DOT sci DOT fi> <37f173b9 DOT 2534667 AT newsserver DOT cc DOT monash DOT edu DOT au> <7su21s$9rk$1 AT solomon DOT cs DOT rose-hulman DOT edu> NNTP-Posting-Host: mercury.st.hmc.edu Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: nntp1.interworld.net 938648713 30478 134.173.45.219 (29 Sep 1999 23:45:13 GMT) X-Complaints-To: usenet AT nntp1 DOT interworld DOT net NNTP-Posting-Date: 29 Sep 1999 23:45:13 GMT X-Mailer: Mozilla 4.61 [en] (X11; U; Linux 2.2.13pre12 i586) X-Accept-Language: en To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Damian Yerrick wrote: > Davin, your solution is IMHO not the best. Passing structures > on the stack is inefficient. The best way to return a structure is > to fill in a blank structure pointed to in the arguments. Sometimes. Actually, returning structures is implemented like this underneath (the function is given a pointer which tells it where to place the returned struct). If GCC were smarter it could optimize the temporary local struct out of existence (and perhaps it does for sufficiently simple cases, I haven't checked). [...] > Davin, I challenge you to find one C library function that returns > a struct on the stack. :-) Can an outsider play? `div' Unix has some in networking functions, like `inet_makeaddr'. -- Nate Eldredge neldredge AT hmc DOT edu