Structures

Henry Spencer henry at utzoo.uucp
Tue Mar 6 04:32:44 AEST 1990


In article <4390 at daffy.cs.wisc.edu> schaut at cat9.cs.wisc.edu (Rick Schaut) writes:
>| 2] It seems that passing a structure-by-value is illegal under this rule.
>| Why this limitation in the original C?
>
>Because C was originaly written for a DEC PDP11 which only had 64K of
>ram.  Under those conditions, passing structures by value simply takes
>up too much stack space.

You'd be amazed at how many programs used to fit comfortably in 64KB before
people with financial interests in memory sales got hold of them...  The
first compiler with struct passing and returning was Dennis's pdp11 one,
which had many happy users for a long time.

>It's a warning because most people (including me) still try to restrict
>themselves to passing only pointers to structures.  I'm not even sure why
>you'd ever want to pass a structure by value...

The main motive for this, in my experience, is when you're essentially
building your own data types (complex numbers in sci/eng number-crunching,
two-dimensional coordinates in graphics, etc.) and want to treat them as
if they were ordinary values.  Passing pointers gets troublesome very
quickly in such situations.
-- 
MSDOS, abbrev:  Maybe SomeDay |     Henry Spencer at U of Toronto Zoology
an Operating System.          | uunet!attcan!utzoo!henry henry at zoo.toronto.edu



More information about the Comp.lang.c mailing list