designated-initializers.c [plain text]
struct foo {
void *a;
int b;
};
union { int i; float f; } u = { };
union { int i; double f; } u2 = { };
union { double f; int i; } u3 = { };
int b[2] = {
[1] = 22
};
struct ds {
struct {
struct {
short a;
};
short b;
struct {
short c;
};
};
};
struct ds ds0 = { { { .a = 0 } } };
struct ds ds1 = { { .a = 1 } };
struct ds ds2 = { { .b = 1 } };
struct ds ds3 = { .a = 0 };
struct ds ds4 = { .c = 1 };
struct ds ds5 = { { { .a = 0 } }, .b = 1 };
struct ds ds6 = { { .a = 0, .b = 1 } };
struct ds ds7 = {
{ {
.a = 1
} },
.a = 2,
.b = 3
};
void test1(int argc, char **argv)
{
static struct foo foo = {
.b = 1024,
};
union { int i; float f; } u2 = { };
union { int i; float f; } u3;
}
struct S {
int nkeys;
int *keys;
union {
void *data;
};
};
void test2() {
struct S *btkr;
*btkr = (struct S) {
.keys = 0,
{ .data = 0 },
};
}