结构体数组初始化报错

Moderator: ESP_ZT

gezhia
Posts: 38
Joined: Thu Nov 24, 2022 10:45 am

结构体数组初始化报错

Postby gezhia » Mon Jan 16, 2023 4:11 pm

程序编译后报错:missing braces around initializer [-Werror=missing-braces],改如何处理?

Code: Select all

typedef struct 
{
	unsigned char Index[4];	
	unsigned char Msk[24];
}typFNT_GB12; 


const typFNT_GB12 tfont12[]=
{
{"中",0x20,0x00,0x20,0x00,0x20,0x00,0xFE,0x03,0x22,0x02,0x22,0x02,0x22,0x02,0xFE,0x03,
0x22,0x02,0x20,0x00,0x20,0x00,0x20,0x00},/*"中",0*/
{"景",0xFC,0x01,0x04,0x01,0xFC,0x01,0x04,0x01,0xFC,0x01,0x20,0x00,0xFF,0x07,0x04,0x01,
0xFC,0x01,0x20,0x00,0x24,0x01,0x32,0x02},/*"景",1*/
{"园",0xFE,0x07,0x02,0x04,0xFA,0x04,0x02,0x04,0x02,0x04,0xFE,0x05,0x52,0x04,0x52,0x04,
0x4A,0x05,0x86,0x05,0x02,0x04,0xFE,0x07},/*"园",2*/
{"电",0x10,0x00,0x10,0x00,0xFF,0x01,0x11,0x01,0x11,0x01,0xFF,0x01,0x11,0x01,0x11,0x01,
0xFF,0x01,0x11,0x04,0x10,0x04,0xE0,0x07},/*"电",3*/
{"子",0x00,0x00,0xFC,0x01,0x80,0x00,0x40,0x00,0x20,0x00,0x20,0x00,0xFF,0x07,0x20,0x00,
0x20,0x00,0x20,0x00,0x20,0x00,0x38,0x00},/*"子",4*/

};


ESP_ZB2
Posts: 21
Joined: Wed Dec 28, 2022 12:33 pm

Re: 结构体数组初始化报错

Postby ESP_ZB2 » Tue Jan 17, 2023 10:51 am

  1. typedef struct
  2. {
  3.     unsigned char Index[4];
  4.     unsigned char Msk[24];
  5. }typFNT_GB12;
  6.  
  7.  
  8. const typFNT_GB12 tfont12[]=
  9. {
  10. {{"中"},{0x20,0x00,0x20,0x00,0x20,0x00,0xFE,0x03,0x22,0x02,0x22,0x02,0x22,0x02,0xFE,0x03,
  11. 0x22,0x02,0x20,0x00,0x20,0x00,0x20,0x00}},/*"中",0*/
  12. {{"景"},{0xFC,0x01,0x04,0x01,0xFC,0x01,0x04,0x01,0xFC,0x01,0x20,0x00,0xFF,0x07,0x04,0x01,
  13. 0xFC,0x01,0x20,0x00,0x24,0x01,0x32,0x02}},/*"景",1*/
  14. {{"园"},{0xFE,0x07,0x02,0x04,0xFA,0x04,0x02,0x04,0x02,0x04,0xFE,0x05,0x52,0x04,0x52,0x04,
  15. 0x4A,0x05,0x86,0x05,0x02,0x04,0xFE,0x07}},/*"园",2*/
  16. {{"电"},{0x10,0x00,0x10,0x00,0xFF,0x01,0x11,0x01,0x11,0x01,0xFF,0x01,0x11,0x01,0x11,0x01,
  17. 0xFF,0x01,0x11,0x04,0x10,0x04,0xE0,0x07}},/*"电",3*/
  18. {{"子"},{0x00,0x00,0xFC,0x01,0x80,0x00,0x40,0x00,0x20,0x00,0x20,0x00,0xFF,0x07,0x20,0x00,
  19. 0x20,0x00,0x20,0x00,0x20,0x00,0x38,0x00}},/*"子",4*/
  20. };

gezhia
Posts: 38
Joined: Thu Nov 24, 2022 10:45 am

Re: 结构体数组初始化报错

Postby gezhia » Wed Jan 18, 2023 3:18 am

谢谢解答!问题已经解决。

Who is online

Users browsing this forum: No registered users and 7 guests