passing structures

Michael J. Eager eager at ringworld.Eng.Sun.COM
Wed Oct 24 10:46:15 AEST 1990


In article <1990Oct13.150132.9257 at warwick.ac.uk> cudcv at warwick.ac.uk (Rob McMahon) writes:
>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.

Structure constants were suggested to the ANSI C committee by several
people, myself included.  There wasn't adequate support nor adequate 
prior art.  Perhaps it will be in the next revision.

-- Mike Eager
>



More information about the Comp.lang.c mailing list