Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!taumet!steve From: steve@taumet.com (Stephen Clamage) Newsgroups: comp.lang.c Subject: Re: passing structures Message-ID: <473@taumet.com> Date: 11 Oct 90 15:35:05 GMT References: <241@motto.UUCP> Organization: Taumetric Corporation, San Diego Lines: 22 andrew@motto.UUCP (Andrew Walduck) writes: |In the new ANSI standard, we can now pass (and return) a structure by |value. Like so...(fragment follows) |typedef struct complex { int real; int imag; } complex; |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 was never possible to create such an anonymous structure constant in Classic C, and is still not possible in ANSI C. You can however do this easily in C++, where such things are fully supported. -- Steve Clamage, TauMetric Corp, steve@taumet.com