-Wmissing-field-initializer使用指定的初始值设定项时

我正在使用GCC 4.6.2(Mingw)并使用-Wextra编译。 每当我使用指定的初始化程序时,我都会收到奇怪的警告。 对于以下代码

 typedef struct { int x; int y; } struct1; typedef struct { int x; int y; } struct2; typedef struct { struct1 s1; struct2 s2[4]; } bug_struct; bug_struct bug_struct1 = { .s1.x = 1, .s1.y = 2, .s2[0].x = 1, .s2[0].y = 2, .s2[1].x = 1, .s2[1].y = 2, .s2[2].x = 1, .s2[2].y = 2, .s2[3].x = 1, .s2[3].y = 2, }; 

我收到警告

 bug.c:24:3: warning: missing initializer [-Wmissing-field-initializers] bug.c:24:3: warning: (near initialization for 'bug_struct1.s1.y') [-Wmissing-field-initializers] 

究竟究竟缺少了什么? 我已经初步确定了每个成员。 这个警告是否过于生硬,无法使用指定的初始化程序,我做错了什么,还是编译错误?

正如你所说,警告似乎是“太生硬了”。

这种访问模式,作为一个整体初始化每个成员结构,满足编译器:

 bug_struct bug_struct1 = { .s1 = {.x = 1, .y = 2}, .s2[0] = {.x = 1, .y = 2}, .s2[1] = {.x = 1, .y = 2}, .s2[2] = {.x = 1, .y = 2}, .s2[3] = {.x = 1, .y = 2} };