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

Incomplete types[edit]

An incomplete type is a structure or union type whose members have not yet been specified, an array type 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 recursive 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 data hiding; the incomplete type is defined in a header file, and the body only within the relevant source file.

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

Incomplete types-不完全类型的更多相关文章

  1. User-Defined Table Types 用户自定义表类型

    Location 数据库--可编程性--类型--用户定义表类型 select one database--> programmability-->types-->user--defi ...

  2. Oracle存储过程 输出参数赋值异常:“Oracle.DataAccess.Types.OracleString”的类型初始值设定项引发异常。

    场景: 写了一个有返回参数的存储过程,在个另开发人员机器上都正常.其它机器报如题错误.让人郁闷的是,所有调用方都是客户端,根本不存在网上众贴所说的版本不一致问题. 分析: 虽然网上的帖子没有根本解决问 ...

  3. Covariant Returen Types(协变返回类型)

    基类virtual func返回类型为某个类(class Super)的ptr或ref,子类重写的virtual func返回类型可改为该类子类(class Sub : public Super)的p ...

  4. mysql string types ---- mysql 字符类型详解

    一.mysql 中包涵的字符类型: [national] char [(m)] [character set charset_name] [collate collation_name] [natio ...

  5. mysql numberic types ---- mysql 数值类型详解

    编程语言中大多都有数据类型一说.虽然mysql 的sql 语句与标准sql 有别.但是宏观上看还是差不多的:下面我们说一下mysql数据库中的数值类型 一.在mysql里有那些类型可以表示数值: 1. ...

  6. Go语言规格说明书 之 类型(Types)

    go version go1.11 windows/amd64 本文为阅读Go语言中文官网的规则说明书(https://golang.google.cn/ref/spec)而做的笔记,完整的介绍Go语 ...

  7. 【12c】扩展数据类型(Extended Data Types)-- MAX_STRING_SIZE

    [12c]扩展数据类型(Extended Data Types)-- MAX_STRING_SIZE 在12c中,与早期版本相比,诸如VARCHAR2, NAVARCHAR2以及 RAW这些数据类型的 ...

  8. C语言的不完整类型和前置声明(转)

    声明与定义(Declaration and Definition) 开始这篇文章之前,我们先弄懂变量的declaration和definition的区别,即变量的声明和定义的区别. 一般情况下,我们这 ...

  9. .Net 中的反射(查看基本类型信息) - Part.2

    反射概述 和Type类 1.反射的作用 简单来说,反射提供这样几个能力:1.查看和遍历类型(及其成员)的基本信息和程序集元数据(metadata):2.迟绑定(Late-Binding)方法和属性.3 ...

随机推荐

  1. POJ 1611 The Suspects【并查集】

    解题思路:一共给出 n个人,m组,接下来是m组数据,每一组开头是该组共有的人 num,则接下来输入的num个数,这些数是一组的 又因为最开始只有编号为0的人携带有病毒,且只有同一组的人会相互传染,问最 ...

  2. Linux中删除特殊符号文件名文件

    Linux 系统下的文件名长度最多可到256个字符.通常情况下,文件名的字符包括:字母.数字.“.”(点).“_”(下划线)和“-”(连字符). Linux 允许在文件名中使用除上述符号之外的其它符号 ...

  3. java中端口号被占用的解决办法

    第一步,命令提示符号,执行命令:netstat -ano 可见,占用1099端口的进程的PID是10460. 第二步,命令提示符号,执行命令:tasklist(通过pid 10460定位) 可见,该占 ...

  4. zabbix_agent代理端监控FTP服务

    (FTP服务器) 监控agent的Linux主机我们在之前就已经做好了,现在直接安装ftp服务即可 (可以看上一遍文章如何搭建监控端agent)  这里不过多演示 [root@agent ~]# yu ...

  5. Mysql 分库分表方案

    0 引言 当一张表的数据达到几千万时,你查询一次所花的时间会变多,如果有联合查询的话,我想有可能会死在那儿了.分表的目的就在于此,减小数据库的负担,缩短查询时间. mysql中有一种机制是表锁定和行锁 ...

  6. SyntaxError Generator expression must be parenthesized

    环境: Windows10 python3.7.0 Django1.11.15 异常 启动Django时抛出以下异常: Unhandled exception in thread started by ...

  7. BZOJ 2049 [SDOI2008]洞穴勘测 (LCT)

    题目大意:维护一个森林,支持边的断,连,以及查询连通性 LCT裸题 洛谷P2147传送门 1A了,给自己鼓鼓掌 #include <cstdio> #include <algorit ...

  8. hadoop中HDFS文件系统 nameNode出现的问题 nameNode无法打开

    1,修改core-site.xml文件,先改成localhost,将所有进程关闭stop-all.sh(或者是先关闭所有进程,然后再修改文件),然后重启,在修改core-site.xml文件成ip地址 ...

  9. W10子系统UBantu命令安装Redis及其启动

    W10子系统UBantu命令安装Redis及其启动 打开W10子系统UBantu 安装Redis $sudo apt-get install redis-server 启动Redis redis-se ...

  10. windows关于定时执行的php脚本

    根据业务需求,需要服务器每天定时执行一些脚本,如后台提交数据,定时处理数据库等. 最初的思路是在某个控制器里写好方法,加入code验证,定期的用计划任务去访问.由于window计划任务这方面比较low ...