以下声明的声明的类型不得为不完整的类型的含义是什么? [英] What is the meaning of statement below that the declared type shall not be incomplete type

查看:101
本文介绍了以下声明的声明的类型不得为不完整的类型的含义是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

声明的类型不得为不完整的类型"是什么意思?

What does it mean that "the declared type shall not be an incomplete type"?

推荐答案

这意味着您不能拥有:

static int arr[]; // This is illegal as per the quoted standard.
int main(void) {}

数组arr是临时定义的,具有不完整的类型(缺少有关对象大小的信息),还具有内部链接(staticarr具有内部链接).

The array arris tentatively defined and has an incomplete type (lacks information about the size of the object) and also has internal linkage (static says arr has internal linkage).

以下内容(在文件范围内)

Whereas the following (at file scope),

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.

有效.

这篇关于以下声明的声明的类型不得为不完整的类型的含义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆