Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
687 views
in Technique[技术] by (71.8m points)

c - gcc warning: braces around scalar initializer

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

What does this warning mean? How should I initialize this LUT? Am I making a mistake in initializing this structures?

Help!!


typedef struct TECH
{

    float velocity1, velocity2;
    float temp;
    float measure;

    int id;
    float storage[64];

}TECH;

struct TECH lut_model_1[2] = {{{296.001465},
        {74.216972},
        {2.025908},
        {1.516384},
        {1},
        {0.001746,
        0.000256, 0.006216, 0.005249, -0.001668, -0.001377, 0.009865, 0.010454, -0.000288, -0.005853, 0.010584, 0.015440, 0.000465, -0.000602, 0.004330, 0.005700, 0.017120,
        0.233015, 0.034154, 0.244022, 0.007644, 0.385683, 0.042960, 0.406633, -0.007811, 0.346931, 0.040123, 0.387361, 0.007030, 0.225309, 0.017897, 0.241024, 0.003700,
        0.103601, 0.060748, 0.121059, -0.045041, 0.076974, 0.070647, 0.148810, -0.022399, 0.074007, 0.054797, 0.141794, 0.010376, 0.052482, 0.045013, 0.078443, -0.019940,
        -0.057353, 0.044285, 0.066622, -0.058232, -0.093817, 0.064753, 0.126611, -0.008286, -0.085634, 0.029582, 0.140443, 0.009189, -0.052974, 0.036057, 0.087536}},

        {{309.270569},
        {74.520226},
        {2.088673},
        {1.595730},
        {1},
        {-0.003261,
        0.001452, 0.006673, 0.007092, 0.001020, 0.002904, 0.009037, 0.009587, -0.001494, 0.000296, 0.009327, 0.010013, -0.000301, -0.002727, 0.005875, 0.008888, -0.016850,
        0.231185, 0.029758, 0.241629, 0.009411, 0.382748, 0.057553, 0.407984, -0.019496, 0.393691, 0.045355, 0.411033, -0.019787, 0.185746, 0.027101, 0.216863, 0.010189,
        0.050463, 0.041380, 0.059462, 0.009747, 0.093188, 0.089831, 0.132579, -0.049612, 0.058789, 0.075130, 0.122026, -0.022185, 0.017041, 0.035450, 0.074255, -0.002068,
        -0.061219, 0.040752, 0.087084, -0.013021, -0.106098, 0.066566, 0.140099, -0.041966, -0.073433, 0.055231, 0.125908, -0.003481, -0.050690, 0.017257, 0.085251}}};
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You should remove the braces: { and } around single values.

struct TECH lut_model_1[2] = {{296.001465,
        74.216972,
        2.025908,
        1.516384,
        1,
        {0.001746,
        0.000256, 0.006216, 0.005249, -0.001668, -0.001377, 0.009865, 0.010454, -0.000288, -0.005853, 0.010584, 0.015440, 0.000465, -0.000602, 0.004330, 0.005700, 0.017120,
        0.233015, 0.034154, 0.244022, 0.007644, 0.385683, 0.042960, 0.406633, -0.007811, 0.346931, 0.040123, 0.387361, 0.007030, 0.225309, 0.017897, 0.241024, 0.003700,
        0.103601, 0.060748, 0.121059, -0.045041, 0.076974, 0.070647, 0.148810, -0.022399, 0.074007, 0.054797, 0.141794, 0.010376, 0.052482, 0.045013, 0.078443, -0.019940,
        -0.057353, 0.044285, 0.066622, -0.058232, -0.093817, 0.064753, 0.126611, -0.008286, -0.085634, 0.029582, 0.140443, 0.009189, -0.052974, 0.036057, 0.087536}},

        {309.270569,
        74.520226,
        2.088673,
        1.595730,
        1,
        {-0.003261,
        0.001452, 0.006673, 0.007092, 0.001020, 0.002904, 0.009037, 0.009587, -0.001494, 0.000296, 0.009327, 0.010013, -0.000301, -0.002727, 0.005875, 0.008888, -0.016850,
        0.231185, 0.029758, 0.241629, 0.009411, 0.382748, 0.057553, 0.407984, -0.019496, 0.393691, 0.045355, 0.411033, -0.019787, 0.185746, 0.027101, 0.216863, 0.010189,
        0.050463, 0.041380, 0.059462, 0.009747, 0.093188, 0.089831, 0.132579, -0.049612, 0.058789, 0.075130, 0.122026, -0.022185, 0.017041, 0.035450, 0.074255, -0.002068,
        -0.061219, 0.040752, 0.087084, -0.013021, -0.106098, 0.066566, 0.140099, -0.041966, -0.073433, 0.055231, 0.125908, -0.003481, -0.050690, 0.017257, 0.085251}}};

will give no warning.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...