gcc warning: braces around scalar initializer

后端 未结 5 1855
旧时难觅i
旧时难觅i 2020-12-05 23:58

I have look-up-table as defined below and I\'m making use of GCC. When I compile I get warnings as

warning: braces around scalar initializer
<
5条回答
  •  情书的邮戳
    2020-12-06 00:13

    This is a scalar initializer: int foo = 3;
    This is a scalar initializer with braces around it: int foo = {3};
    This is an initializer of an array, which isn't scalar: int foo[] = {1, 2, 3};

    The warning says that your struct has scalar initializers with braces around them:

    typedef struct TECH
    {
    
        float velocity1, velocity2;
    ...
    
    struct TECH lut_model_1[2] = {{{296.001465},
        {74.216972},
    ...
    

    Your code will work, it just has superfluous braces around its scalar initializers. If you take the braces out and format it a little more nicely (I'd put the first initializer on its own line) there will be nothing objectionable about it.

提交回复
热议问题