[comp.lang.c] did old compilers give warning on &struct?

ejp@bohra.cpg.oz (Esmond Pitt) (11/13/89)

In article <465@siswat.UUCP> buck@siswat.UUCP (A. Lester Buck) writes:
>In a recent discussion with a co-worker, he claimed that several (many?)
>early C compilers, before the support of structure passing, would give a
>warning if there was an & before a structure in a function call, similar to
>the (correct) warning for an & before an array.  He claims he and many
>others wrote a lot of code that removed the & to shut up the warnings, but
>were then caught when a later version of these compilers started supporting
>structure passing.
>
>I have _never_ heard of or used such a brain-dead compiler.  Did such
>compilers exist, and can I run into large pieces of code that don't have &
>before struct parameters passed by reference?

Before structure name arguments => pass by reference was supported,
structure name arguments were passed _by_value_. Therefore your
co-worker seems to have it back to front: as the programmer at that
time probably intended a pass-by reference rather than stacking some
potentially huge structure, there may have been C compilers which
complained if the & was _missing_. Indeed the compiler may not have
supported passing aggregates by value. (I have never seen either
behaviour.)


-- 
Esmond Pitt, Computer Power Group
ejp@bohra.cpg.oz

henry@utzoo.uucp (Henry Spencer) (11/14/89)

In article <112@bohra.cpg.oz> ejp@bohra.cpg.oz (Esmond Pitt) writes:
>Before structure name arguments => pass by reference was supported,
>structure name arguments were passed _by_value_...

Uh, I think you have this backward.  Passing a struct to a function is
done by value in modern C.  Back before this feature was introduced,
some compilers would implicitly turn a struct name into a pointer to
that struct, as still happens for arrays.  Some such compilers did
grumble about &array, and may well have done the same about &struct
(I don't remember for sure).
-- 
A bit of tolerance is worth a  |     Henry Spencer at U of Toronto Zoology
megabyte of flaming.           | uunet!attcan!utzoo!henry henry@zoo.toronto.edu