<分区>
在C语言中,灵活数组成员的语法是这样的:
struct s
{
int n;
double d[]; // flexible array member
};
并且,零大小数组在 C 语言中是非法的。
如果我这样声明数组:
struct s
{
double d[0]; // Zero size array
};
GCC 发出警告:
warning: ISO C forbids zero-size array 'd' [-Wpedantic]
那么,我要回答我的主要问题了。
我看到了以下代码 here .
struct squashfs_xattr_entry {
__le16 type;
__le16 size;
char data[0];
};
在 C 中,零大小数组是非法的。
然后,
data[0]
在结构中声明的目的是什么?data[0]
在这里做什么?