[Libosinfo] [PATCH] tools: Fix compilation with Clang 6

Eric Blake eblake at redhat.com
Fri May 11 15:10:49 UTC 2018


On 05/11/2018 10:01 AM, Andrea Bolognani wrote:
> Clang 6 doesn't like the way the last item in a GOptionEntry
> array is initialized:
> 
>    ../../tools/osinfo-install-script.c:87:12: error: missing field
>    'short_name' initializer [-Werror,-Wmissing-field-initializers]
>        { NULL }
>               ^

Does it work without warning with the simpler:

{ 0 }

which is supposed to be the universal 0-initializer?

Does it work with the gcc/clang extension of:

{}

(even though the C standard does not describe that form)?

Does it work if you used a named initializer, as in:

{ .foo = NULL }

Otherwise, the fact that you have to spell out multiple fields feels 
like a bug in clang giving pointless warnings.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org




More information about the Libosinfo mailing list