build: Explicitly enable -Wmissing-field-initializers

It was previously only enabled (by default) on macOS, which led to
code being committed which triggered warnings, as that CI job is not
always run.

Avoid that risk by always enabling the warning.

The reasoning for using this warning is that explicit initialisation is
clearer than implicit. We also want to support GLib’s public headers
being used in projects which build with
`-Werror=missing-field-initializers`, but can’t easily enable the
warning for our public headers but not our internal code. So enable it
everywhere.

Make it a warning rather than an error, as there’s a risk that system
header changes will trigger it in distro release builds, which would
cause false build failures. By making it a warning, GLib developers can
build with `-Werror` and promote it to an error, while distros can
choose not to.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #2812
This commit is contained in:
Philip Withnall 2022-11-16 10:42:29 +00:00
parent 4f406f3de6
commit 7d55571c13

View File

@ -477,6 +477,7 @@ if cc.get_id() == 'gcc' or cc.get_id() == 'clang'
'-Wduplicated-branches',
'-Wimplicit-fallthrough',
'-Wmisleading-indentation',
'-Wmissing-field-initializers',
'-Wnonnull',
'-Wunused',
# Due to maintained deprecated code, we do not want to see unused parameters