In godbolt: https://godbolt.org/z/bY1a3e1Wz
the code in question is below (the error message says "error: either all initializer clauses should be designated or none of them should be" but I dont understand what it is saying..
struct A {
int a;
bool b;
};
struct B : A {
long c;
};
int main(void) {
B foo {{.a = 1, .b = false}, .c = 7};
}
From what I see in the docs, it looks like this should work:
B foo = {{.a = 1, .b = false}, 7};
The reason seems to be that the first initializer is "nameless" (by order) and so the second one (c
) should also be initialized by order rather than by name (it can not be designated
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With