在C中的Struct初始化const数组

时间:2012-10-23 14:33:20

标签: c embedded

代码段:

static struct
{
     static const unsigned char myConstArray[] =
     {
           50, 51, 52, 52, 53, 54, 55, 55, 56, 57, 58, 58, 59, 60,
     };

     //more....
 }_SomeValues;

这怎么可行? (抱怨在= a之后;缺少)

3 个答案:

答案 0 :(得分:8)

更改为:

static struct
{
     const unsigned char myConstArray[14];

} _SomeValues =
    {
        {
           50, 51, 52, 52, 53, 54, 55, 55, 56, 57, 58, 58, 59, 60,
        }
    };

答案 1 :(得分:1)

你不能在struct

中拥有静态变量

答案 2 :(得分:1)