From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <599f06db0812040426u435f5a9dx7c1c0209c333db53@mail.gmail.com> Date: Thu, 4 Dec 2008 13:26:55 +0100 From: "Gorka Guardiola" To: "Fans of the OS Plan 9 from Bell Labs" <9fans@9fans.net> In-Reply-To: <599f06db0812040407g59ee4feejc79ce8ecdec30451@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <599f06db0812040407g59ee4feejc79ce8ecdec30451@mail.gmail.com> Subject: Re: [9fans] initialization of anonymous structs. Topicbox-Message-UUID: 58be7cf8-ead4-11e9-9d60-3106f5b1d025 On Thu, Dec 4, 2008 at 1:07 PM, Gorka Guardiola wrote: > Say I have a couple of structs like: > > typedef struct A A; > typedef struct B B; > > struct A > { > int a1; > int a2; > }; > > struct B > { > A; > int b1; > int b2; > }; > > Now I want to declare a variable of kind B with parts initialized. Is > there anyway to initialize the A inside the B?. I have tried: > > B bvar = { > .a1 2 > .b1 2 > }; > There is a way, with a display, but I wanted to name the fields. This works: B bvar = { 0, 0, 0, 0 }; I guess I can always add comments. -- - curiosity sKilled the cat