[pulseaudio-discuss] Allowing anonymous structs and unions
Tanu Kaskinen
tanuk at iki.fi
Tue Sep 22 23:12:53 PDT 2015
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.
Anonymous unions look similar:
struct foo {
union {
int i;
float f;
};
};
struct foo f;
f.i = 1;
f.f = 2.0;
--
Tanu
More information about the pulseaudio-discuss
mailing list