Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!taumet!steve From: steve@taumet.com (Stephen Clamage) Newsgroups: comp.lang.c Subject: Re: Why didn't ANSI make initialisation consistent ???? Message-ID: <692@taumet.com> Date: 25 Apr 91 18:04:33 GMT References: <1991Apr24.141206.18103@grep.co.uk> Organization: Taumetric Corporation, San Diego Lines: 36 vic@grep.co.uk (Victor Gavin) writes: >... Which made me believe that I could use the following code: > struct bert { int a, b; } > struct fred { struct bert *abc; } blip = { {1,1} }; >[[ie That the compiler will place the data for the structure into one of the >data segments and then place it's address into the pointer variable.]] >Could anyone tell me whether the ANSI committee pondered over the problem of >tidying up the inconsistencies of the C initializations ? IMHO, this is not an inconsistency. There is no way to specify an anonymous aggregate constant in C. Further, if we accept the syntax you show, it would have to try to assign the aggregate constant to a pointer, which would be rejected in any case. You would need something more like this: struct fred { struct bert *abc; } blip = { &{1,1} }; This has some problems, in that {1, 1} has no type. Bracketed initializers are syntactic ways to supply values to members of the aggregate being initialized. "{1,1}" has no meaning on its own. You would need to extend the C language to support anonymous aggregate constants, perhaps along the lines of (struct bert){1, 1} (This is not a recommendation.) I don't know whether X3J11 ever discussed such a thing, but I'm sure they would have considered it outside their purview, there being no such existing practice. BTW, if one struct is "bert", shouldn't the other be "ernie"? -- Steve Clamage, TauMetric Corp, steve@taumet.com