suggestion for C/C++ warning
Jakub Jelinek
jakub@redhat.com
Tue Sep 21 07:59:00 GMT 2004
On Tue, Sep 21, 2004 at 02:48:24PM +0930, William Brodie-Tyrrell wrote:
> Would it be possible to add a warning if a struct is not completely
> initialised from a literal? eg:
>
> typedef struct {
> int a, b, c;
> } foo_t;
>
> foo_t goodfoo = {1, 2, 3}; // ok
> foo_t badfoo = {4, 5}; // warning?
>
>
> Clearly use of a constructor is preferable to this initialisation style, but
> for maintenance purposes it would be very nice to catch all the places
> where a struct is badly initialised after a new member has been added to the
> definition.
-Wmissing-field-initializers
(-W enables -Wmissing-field-initializers too unless explicitely overridden).
Jakub
More information about the Gcc
mailing list