passing structures

Rob McMahon cudcv at warwick.ac.uk
Sun Oct 14 01:01:32 AEST 1990


In article <241 at motto.UUCP> andrew at motto.UUCP (Andrew Walduck) writes:
>complex add(complex, complex); /* function prototype for complex add */
>...
>Now, here's the problem...what if I wanted to pass a constant structure
>to add! For example I wanted to add 5+8i to a:
>...
>result = add(a,{5,8});
>
>But this isn't supported by ANSII! There's no way to pass a structure as a
>parameter! It should be do-able, the prototype exists, so the types can be
>punned appropriately...any idea why it wasn't? No prior-art?

It is do-able, You can do this in GCC, although you still need a cast:

  result = add(a,(complex){5,8});

So there is some prior art, but ...

>Any idea how I can suggest this to the committee?

... you're much too late to get it into ANSI-C this time round, so any use
will be completely non-portable.  Still, if it proves useful enough, and other
vendors take up the idea, it may make it in next time.

Rob
--
UUCP:   ...!mcsun!ukc!warwick!cudcv	PHONE:  +44 203 523037
JANET:  cudcv at uk.ac.warwick             INET:   cudcv at warwick.ac.uk
Rob McMahon, Computing Services, Warwick University, Coventry CV4 7AL, England



More information about the Comp.lang.c mailing list