我收到以下警告:
test.c:8:1: warning: missing braces around initializer [-Wmissing-braces]
static foo x = {0.0f, 0.0f, 0.0f};
^
test.c:8:1: warning: (near initialization for ‘x.a’) [-Wmissing-braces]
我正在用gcc -Wall test.c
编译
这是我的代码:
#include <stdio.h>
typedef struct
{
float a[3];
}foo;
static foo x = {0.0f, 0.0f, 0.0f};
int main()
{
printf("%lf", x.a[0]);
return 0;
}
我是否不正确地初始化x?
当我不使用-Wall进行编译时,它可以工作。
发布于 2015-02-25 06:39:04
在形式上,您的初始化应如下所示:
static foo x = {{0.0f, 0.0f, 0.0f}};
https://stackoverflow.com/questions/28712689
复制相似问题