ANSI C questions (parameters, structure assignment)
Richard Tobin
richard at aiai.ed.ac.uk
Fri Aug 24 02:45:20 AEST 1990
In article <1081.26d26274 at desire.wright.edu> demon at desire.wright.edu writes:
> 1) In standard C, when you pass a structure bigger than four
>longwords, is the structure passed as a value parameter, or just a pointer to
>the structure (thus making it a var parameter)?
Structures are passed by value regardless of their size.
Whether this is implemented by actually putting the structure on the
stack, or by passing a pointer to a copy of it, is invisible to the
programmer.
[Actually, it's only invisible to the *correct* programmer. I recently
forgot to put "&" before the name of a structure I was passing. This
made no difference on a Sun 4 (which passes the structure by putting
the address in a register) and I didn't discover the error until I
compiled it on a Sun 3.]
> 2) Are structure assignments allowed only for initializations
No. Structure assignments are fine in ANSI C.
>struct_thing -= still_more_struct;
>struct_thing *= even_more_struct;
But I don't know what these are supposed to mean. What do you expect
subtracting structures to do?
-- Richard
--
Richard Tobin, JANET: R.Tobin at uk.ac.ed
AI Applications Institute, ARPA: R.Tobin%uk.ac.ed at nsfnet-relay.ac.uk
Edinburgh University. UUCP: ...!ukc!ed.ac.uk!R.Tobin
More information about the Comp.lang.c
mailing list