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

kaisey
Posts: 81
Joined: Tue Mar 24, 2020 5:54 am

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

Postby kaisey » Fri Jun 25, 2021 1:57 pm

这个编译器好像不支持大括号级联,
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;
{
},
}

ESP_Gargamel
Posts: 786
Joined: Wed Nov 14, 2018 8:45 am

Re: 结构体数组初始化

Postby ESP_Gargamel » Mon Jun 28, 2021 1:38 am

你 app_para_audio_data_t 定义是什么?你这是个数组。你试一下:

Code: Select all

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

kaisey
Posts: 81
Joined: Tue Mar 24, 2020 5:54 am

Re: 结构体数组初始化

Postby kaisey » Mon Jun 28, 2021 5:54 am

按你的方法修改了就不报错了,这有点神奇,OK了

Who is online

Users browsing this forum: No registered users and 80 guests