C 标准规定:
If the declaration of an identifier for an object is a tentative definition and has internal linkage, the declared type shall not be an incomplete type
“声明的类型不应是不完整的类型”是什么意思?
最佳答案
这意味着您不能拥有:
static int arr[]; // This is illegal as per the quoted standard.
int main(void) {}
数组 arr
是暂时定义的,类型不完整(缺少关于对象大小的信息),也有内部链接(static
说 arr
有内部链接)。
鉴于以下(在文件范围内),
int i; // i is tentatively defined. Valid.
int arr[]; // tentative definition & incomplete type. A further definition
// of arr can appear elsewhere. If not, it's treated like
// int arr[] = {0}; i.e. an array with 1 element.
// Valid.
有效。
关于c - 下面声明的类型不应是不完整类型的声明是什么意思,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18733204/