Path: utzoo!utgpu!watserv1!watmath!att!rutgers!cs.utexas.edu!sun-barr!newstop!sun!ringworld.Eng.Sun.COM!eager From: eager@ringworld.Eng.Sun.COM (Michael J. Eager) Newsgroups: comp.lang.c Subject: Re: passing structures Message-ID: <144100@sun.Eng.Sun.COM> Date: 24 Oct 90 00:46:15 GMT References: <241@motto.UUCP> <1990Oct13.150132.9257@warwick.ac.uk> Sender: news@sun.Eng.Sun.COM Organization: Sun Microsystems, Mt. View, Ca. Lines: 31 In article <1990Oct13.150132.9257@warwick.ac.uk> cudcv@warwick.ac.uk (Rob McMahon) writes: >In article <241@motto.UUCP> andrew@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 >