Page 1 of 1

结构体数组初始化报错

Posted: Mon Jan 16, 2023 4:11 pm
by gezhia
程序编译后报错: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*/

};


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

Posted: Tue Jan 17, 2023 10:51 am
by ESP_ZB2
  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. };

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

Posted: Wed Jan 18, 2023 3:18 am
by gezhia
谢谢解答!问题已经解决。