-Wmissing-field-initializer when using designated initializers

后端 未结 1 1995
暗喜
暗喜 2020-12-11 19:28

I\'m using GCC 4.6.2 (Mingw) and compiling with -Wextra. I\'m getting strange warnings whenever I use designated initializers. For the following code

         


        
相关标签:
1条回答
  • 2020-12-11 20:10

    It seems that the warning is, as you say, "too blunt".

    This pattern of access, initializing each member struct as a whole, satisfies the compiler:

    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}
    };
    
    0 讨论(0)
提交回复
热议问题