On 23 September 2015 at 11:42, Tanu Kaskinen <tanuk at iki.fi> wrote: > Hi all, > > We haven't been using anonymous structs and unions so far, because > they've been non-standard in the past. C11 added support for them, > however. GCC has supported them longer than that, I don't know about > other compilers. Anonymous structs and unions are nice, and I think we > should start allowing them. Any objections? > > In case the terms aren't clear, an anonymous struct looks like this: > > struct foo { > struct { > int a; > int b; > }; > > int c; > }; > > struct foo f; > f.a = 1; > f.b = 2; > f.c = 3; > > So struct foo contains another struct, but that struct doesn't have a > name. Members of the inner struct are accessed as if they were members > of the outer struct. We spoke about why anonymous structures, and Tanu pointed out its use in the memfd patches. I think it hampers, rather than helps, readability. > Anonymous unions look similar: > > struct foo { > union { > int i; > float f; > }; > }; > > struct foo f; > f.i = 1; > f.f = 2.0; Which is nice to have, indeed. In general, I'm happy to move to C11, though. People who are running non-Linux / non-gcc builds, time to speak up! -- Arun