https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120860
--- Comment #2 from Bruno Haible <bruno at clisp dot org> ---
> Or do you want anything attribute on the fields which are optional.
Either way would be suitable to fix the problem:
* Either an attribute on the struct type, to avoid a
-Wmissing-field-initializers warning for any field of the struct.
* Or an attribute on the field(s) that should not elicit a
-Wmissing-field-initializers warning.
No special-casing of the last field should be done, because the problem occurs
also with the designated-initializer syntax:
{ .name = "foo", .val = 42 }
and therefore the solution should apply to both the
fields-in-their-listed-order syntax and to the designated-initializer syntax.
> It seems like some fields are optional, they are put in another struct
> and then use {} or {0}.
I would like to avoid using a different syntax than the natural one (that is
valid C99!), for example:
- initializing the remaining fields explicitly,
- use of {},
- use of a macro that expands to the remaining field initializers,
- use if a variadic macro that provides the remaining field initializers
when needed,
because these would be workarounds that make the code harder to grasp.
In other words, I want to use the simplest valid C99 syntax.