博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Incomplete types-不完全类型
阅读量:6915 次
发布时间:2019-06-27

本文共 1457 字,大约阅读时间需要 4 分钟。

另外:前向声明中引入的类型为不完全类型(incomplete type),不完全类型只能以有限方式使用,只能用于定义指向该对象的指针和引用,只能用于声明使用该类型作为形参或返回类型的函数。

 

Incomplete types[]

An incomplete type is a  type whose members have not yet been specified, an  whose dimension has not yet been specified, or the void type (the void type cannot be completed). Such a type may not be instantiated (its size is not known), nor may its members be accessed (they, too, are unknown); however, the derived pointer type may be used (but not dereferenced).

They are often used with pointers, either as forward or external declarations. For instance, code could declare an incomplete type like this:

struct thing *pt;

This declares pt as a pointer to struct thing and the incomplete type struct thing. Pointers to data always have the same byte-width regardless of what they point to, so this statement is valid by itself (as long as pt is not dereferenced). The incomplete type can be completed later in the same scope by redeclaring it:

struct thing {    int num; }; /* thing struct type is now completed */

Incomplete types are used to implement  structures; the body of the type declaration may be deferred to later in the translation unit:

typedef struct Bert Bert;typedef struct Wilma Wilma; struct Bert { Wilma *wilma; }; struct Wilma { Bert *bert; };

Incomplete types are also used for ; the incomplete type is defined in a , and the body only within the relevant source file.

 

https://en.wikipedia.org/wiki/C_syntax#Incomplete_types

转载地址:http://sdacl.baihongyu.com/

你可能感兴趣的文章
一行代码更新R语言
查看>>
在hibernate中查询使用list,map定制返回类型
查看>>
我的友情链接
查看>>
我的友情链接
查看>>
String字符串
查看>>
SolarWinds-DesktopToolset
查看>>
我的友情链接
查看>>
Mac sudo 命令不能用报错处理
查看>>
RHEL7上配置NFS服务
查看>>
我的友情链接
查看>>
Vim编辑器
查看>>
linux应用程序的管理
查看>>
利用python监控文件被修改
查看>>
pt(Percona Toolkit)工具详解:(二)工具介绍
查看>>
我的友情链接
查看>>
memcache、redis、mongodb对比
查看>>
关于分布式事务名词的基本解释的读书笔记
查看>>
组成关系映射(映射文件)
查看>>
我的友情链接
查看>>
CI框架中出现Disallowed Key Characters
查看>>