keil结构体成员空数组 #94-D: the size of an array must be greater than zero


使用keil编译一个结构体,有空数组:

 1 #pragma pack(1)
 2 typedef struct //TUIM指令结构
 3 {
 4     u16 stat; //指令的状态,0:等待执行,1:已发送,2:超时,3:正确执行,其他错误
 5     u16 buflen; //指令数据区长度,若为0,说明是用户自己定义的,不释放。
 6     u16 n; //发送数据长度
 7     TUIM_CMD_CB cb; //接收回调函数,0为不要接收
 8     u8 p[0]; //指令指针
 9 } TUIM_CMD;
10 #pragma pack()

结果报了 error: #94-D: the size of an array must be greater than zero

不让用空数组,加了--cpp11和c99都不管用。

后来查了这个:https://developer.arm.com/docs/dui0496/k/c-and-c-compiler-errors-and-warnings/list-of-the-armcc-error-and-warning-messages

说是 Zero-sized arrays are permitted only when in --gnu mode

所以加了--gnu,解决


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM