How to repair warning: missing braces around initializer?

前端 未结 2 711
清酒与你
清酒与你 2020-12-08 18:45

The warning is produced by the c code generated by vala.

warning: missing braces around initializer

The code works but the warni

2条回答
  •  鱼传尺愫
    2020-12-08 18:56

    Yes, this appears to be related to GCC bug 53119. It goes away if you change the C declaration to {{0}}. Your options are:

    1. Ignore the warning.
    2. Manipulate the C code after generation to have {{0}} instead of {0} on that line using sed or the like.
    3. Declare the array extern in Vala, and write the C definition elsewhere. (The permanent version of #2.)
    4. Do something like struct foo { int bar; Position positions[8]; } static foo position_holder and {0} will then be initialising position_holder.bar which is fine and the warning goes away.

提交回复
热议问题