struct Foo {
int x;
int y;
};
struct Bar {
struct Foo f;
};
struct Bar b = {.f.x = 3}; // Error: only 1 designator currently allowed for C struct field initializer
struct Bar b2 = {
.f.x = 3, // Error: only 1 designator currently allowed for C struct field initializer
.f.y = 4,
};
Comment #1 by trikkuz — 2023-10-23T07:20:33Z
Same problem with unions:
union t_union
{
int a;
long b;
};
struct t_struct
{
union t_union u;
};
struct t_struct err = { .u.a = 1 }; // Error: only 1 designator currently allowed for C struct field initializer
Comment #2 by robert.schadek — 2024-12-13T19:24:47Z