在C,柔性阵列构件的语法如下:在struct中这个`data [0]`声明的目的是什么?
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]
在这里做什么?
@chux特别是GNU GCC和Clang。然而,M $ VC拒绝零长度数组。 – iBug
所以你甚至没有谷歌有多少重复呢?! –