Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Use <code>G_VALUE_INIT</code> to initialize <code>GValue</code>-s. Their (private) structure is in <code>/usr/include/glib-2.0/gobject/gvalue.h</code> which <code>#define G_VALUE_INIT</code> appropriately.</p> <p>I strongly disagree with your assessment that it is GCC's bug. You ask to be warned if a field is not explicitly initialized with <code>-Wmissing-field-initializers</code> and you get the warning you deserve. </p> <p>Sadly <code>G_VALUE_INIT</code> is not documented, but it is here. Code with</p> <pre><code>GValue value = G_VALUE_INIT; </code></pre> <p>There is no universal solution to never get the warning about missing field initialization if <code>-Wmissing-field-initializers</code> is asked. When you ask for such a warning, you require the compiler to warn of every incomplete initializers. Indeed, the standard requires than all the non-explicitly initialized <code>struct</code> fields be zeroed, and <code>gcc</code> obeys the standard.</p> <p>You could use <a href="http://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html" rel="noreferrer">diagnostic pragmas</a> like </p> <pre><code>#pragma GCC diagnostic ignored "-Wmissing-field-initializers" </code></pre> <p>But my feeling is that you should code with care, and explicitly initialize all the fields. The warning you get is more a coding style warning (maybe you forgot a field!) than a bug warning.</p> <p>I also believe that for your own (public) <code>struct</code> you should <code>#define</code> an initializing macro, if such <code>struct</code> are intended to be initialized.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload