Use G_VALUE_INIT to initialize GValue -s. Their (private) structure is in /usr/include/glib-2.0/gobject/gvalue.h , which is #define G_VALUE_INIT respectively.
I strongly disagree with your assessment that this is a GCC error. You ask for a warning if the field is not explicitly initialized with -Wmissing-field-initializers , and you get the warning you deserve.
Sadly G_VALUE_INIT not documented, but it is here. Code with
GValue value = G_VALUE_INIT;
There is no one-stop solution to never receive a warning about the lack of field initialization if -Wmissing-field-initializers is specified. When you request such a warning, you require the compiler to warn about each incomplete initializer. In fact, the standard requires that all implicitly initialized struct fields be nullified and gcc obeys the standard.
You can use diagnostic pragmas , for example
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
But I feel that you should code with caution and explicitly initialize all fields. The warning you get is more likely to warn about the coding style (you may have forgotten the field!) Than the warning about the error.
I also believe that for your own (public) struct you must have a #define initializing macro if such struct should be initialized.
source share