From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <599f06db0812040407g59ee4feejc79ce8ecdec30451@mail.gmail.com> Date: Thu, 4 Dec 2008 13:07:59 +0100 From: "Gorka Guardiola" To: "Fans of the OS Plan 9 from Bell Labs" <9fans@9fans.net> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Subject: [9fans] initialization of anonymous structs. Topicbox-Message-UUID: 58acc698-ead4-11e9-9d60-3106f5b1d025 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 }; B bvar = { .a1=2 .b1=2 }; B bvar = { .A { .a1=2} .b1 2 }; B bvar = { .A={ .a1 2} .b1 2 }; B bvar = { .A={2} .b1 2 }; I always get the error that the field does not exist. I have looked at the code of the compiler and run it with -di and have not been able to figure out a way to initialize the anonymous struct. Am I missing something?. Is there a way to do this?. -- - curiosity sKilled the cat