Page 1 of 1

[已解决] 结构体数组初始化

Posted: Fri Jun 25, 2021 1:57 pm
by kaisey
这个编译器好像不支持大括号级联,
const app_para_audio_data_t app_para_audio_data_const[app_para_audio_data_size] =
{
//0
{
0x12345678,//int len;
},
};
这样的初始化就会报错
error: missing braces around initializer [-Werror=missing-braces]
{
^
../main/application/app_para_const/app_para_audio_data_const.c:15:2:
0x12345678,//int len;
{
},
}
../main/application/app_para_const/app_para_audio_data_const.c:12:1: error: missing braces around initializer [-Werror=missing-braces]
{
^
../main/application/app_para_const/app_para_audio_data_const.c:15:2:
0x12345678,//int len;
{
},
}

Re: 结构体数组初始化

Posted: Mon Jun 28, 2021 1:38 am
by ESP_Gargamel
你 app_para_audio_data_t 定义是什么?你这是个数组。你试一下:

Code: Select all

{
{
.x = 0x12345678,
},
{
.x = 0x87654321,
},
};

Re: 结构体数组初始化

Posted: Mon Jun 28, 2021 5:54 am
by kaisey
按你的方法修改了就不报错了,这有点神奇,OK了