Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!tut.cis.ohio-state.edu!unmvax!bbx!bbxsda!scott From: scott@bbxsda.UUCP (Scott Amspoker) Newsgroups: comp.lang.c Subject: Re: Function returning Structure: How does it work? Keywords: structure, struct Message-ID: <772@bbxsda.UUCP> Date: 5 Jun 90 20:17:15 GMT References: <1990May28.215331.29333@agate.berkeley.edu> <1990May28.235336.5338@Neon.Stanford.EDU> <18222@well.sf.ca.us> Reply-To: scott@bbxsda.UUCP (Scott Amspoker) Distribution: usa Organization: Basis International, Albuquerque, NM Lines: 27 In article <18222@well.sf.ca.us> rld@well.sf.ca.us (Rick Davis) writes: >> Of course, this >> can lead to a great deal of copying so most of the time you're better off >> arranging things for the function to have type STRUCT * instead. > >I can't agree with this too strongly. Passing entire structures back >and forth is almost always a serious waste of time and stack space. ...unless the structure can fit in a single word. I've seen compilers which handle that rather nicely. >Also, some implementations of C won't even let you try. Code portability >alone works for me. We been porting our C code to dozens of different platforms and C compilers for the *past 5 years* and have never encountered a C compiler that did not allow structure assignment. Much older compilers, however, might complain. Such compilers typically conform to old K&R and also don't maintain separate name spaces for structure field names. That's asking too much for portability IMHO. -- Scott Amspoker Basis International, Albuquerque, NM (505) 345-5232 unmvax.cs.unm.edu!bbx!bbxsda!scott