本文介绍了如何修复警告:在初始化程序周围丢失大括号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
警告是由vala生成的c代码产生的。代码有效,但警告很烦人。警告引用的vala代码是:
struct Position {uint x; uint y;}
private static Position positions [8];
生成的C代码是
static Position det_positions [8] = {0};
我尝试了六种不同方式的初始化位置,但似乎无法获得语法满足警告。这是还是有办法解决它?
解决方案
是的,这似乎与。如果将C声明更改为 {{0}}
,它就会消失。您的选择是:
- 忽略警告。
- 操作C代码后生成
{{0}}
而不是{0}
使用sed
等。 - 在Vala中声明数组
extern
,并在别处写入C定义。 (#2的永久版本。) - 做一些像
struct foo {int bar;职位[8]; } static foo position_holder
和{0}
然后会初始化position_holder.bar
,它是罚款和警告消失。
The warning is produced by the c code generated by vala.
The code works but the warning is annoying. The vala code referenced by the warning is
struct Position {uint x; uint y;}
private static Position positions[8];
The generated C code is
static Position det_positions[8] = {0};
I've tried initializing positions half a dozen different ways but can't seem to get the syntax to satisfy the warning. Is this GCC bug 53119 or is there a way to fix it?
解决方案
Yes, this appears to be related to GCC bug 53119. It goes away if you change the C declaration to {{0}}
. Your options are:
- Ignore the warning.
- Manipulate the C code after generation to have
{{0}}
instead of{0}
on that line usingsed
or the like. - Declare the array
extern
in Vala, and write the C definition elsewhere. (The permanent version of #2.) - Do something like
struct foo { int bar; Position positions[8]; } static foo position_holder
and{0}
will then be initialisingposition_holder.bar
which is fine and the warning goes away.
这篇关于如何修复警告:在初始化程序周围丢失大括号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!