Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!warwick!cudcv From: cudcv@warwick.ac.uk (Rob McMahon) Newsgroups: comp.lang.c Subject: Re: passing structures Message-ID: <1990Oct13.150132.9257@warwick.ac.uk> Date: 13 Oct 90 15:01:32 GMT References: <241@motto.UUCP> Sender: news@warwick.ac.uk (Network news) Organization: Computing Services, Warwick University, UK Lines: 29 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. Rob -- UUCP: ...!mcsun!ukc!warwick!cudcv PHONE: +44 203 523037 JANET: cudcv@uk.ac.warwick INET: cudcv@warwick.ac.uk Rob McMahon, Computing Services, Warwick University, Coventry CV4 7AL, England