Function returning Structure: How does it work?
Scott Amspoker
scott at bbxsda.UUCP
Wed Jun 6 06:17:15 AEST 1990
In article <18222 at well.sf.ca.us> rld at 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
More information about the Comp.lang.c
mailing list