ANSI C questions (parameters, structure assignment)

Dave Gillett dgil at pa.reuter.COM
Fri Aug 24 10:00:43 AEST 1990


In <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)?
     I believe that all "modern" C compilers pass structures of any size as
value parameters, regardless of size.  Some compilers on some hardware may
pass small structures in registers and larger ones on the stack, or as a pointer
to a copy, or some other mechanism, but it's still a value parameter and your
code should reflect that.

>	2)	Are structure assignments allowed only for initializations
>or can I do:

>struct_thing = other_struct_thing;
>struct_thing -= still_more_struct;
>struct_thing *= even_more_struct;

>etc...

>	I thought I knew the answer to there but VAX C (I know it's not 100%
>ansi) barfs on question #2 type statements of the  -= += etc. kind.

     Recall that "x -= y" is equivalent to "x = x - y".  Will your VAX C let
you get away with "struct_thing = struct_thing - still_more_struct"?  How
have you declared "struct_thing" that lets it both (a) be a structure, and 
(b) be in the domain of subtraction, which normally works on *numbers*???
                                   Dave



More information about the Comp.lang.c mailing list