没有加{ }进行初始化
typedef struct{
uchar led_enable[9];
uchar led_State[8];
struct{
uchar pwm_flags;
uint pwm_flags_count;
uchar pwm_count;
uchar led_Cmp_Buff[8];
uchar led_PWM_enable[9];
}led_pwm_struct;
}led_def;
led_def led_struct =
{
{0,1,0,0,0,0,0,0,
1},
{1,1,0,0,0,0,0,0},
// {
0,
0,
0,
{0,0,0,0,0,0,0,0},
{0,1,0,0,0,0,0,0,
1},
// }
};
bsp_c\led.c(17): error C242: ‘struct’: too many initializers
加{ }进行初始化
typedef struct{
uchar led_enable[9];
uchar led_State[8];
struct{
uchar pwm_flags;
uint pwm_flags_count;
uchar pwm_count;
uchar led_Cmp_Buff[8];
uchar led_PWM_enable[9];
}led_pwm_struct;
}led_def;
led_def led_struct =
{
{0,1,0,0,0,0,0,0,
1},
{1,1,0,0,0,0,0,0},
{
0,
0,
0,
{0,0,0,0,0,0,0,0},
{0,1,0,0,0,0,0,0,
1},
}
};
成功编译
结论:对于简单的可以不用加{},对于比较难的需要加上{},以便于识别,不过,最好还是加上为好