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

本文共 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://mpqna.baihongyu.com/

你可能感兴趣的文章
如何更好的编写async函数
查看>>
【前端工程师手册】JavaScript之this的笔记
查看>>
使用nginx来为你在一台服务器部署多个Web Server
查看>>
G5 Capital 与 SegmentFault 达成战略合作
查看>>
抽象类和接口的区别
查看>>
Vue 组件详解
查看>>
前端面试题-主流浏览器内核
查看>>
JavaScript 进阶知识 - Ajax篇
查看>>
阿里巴巴测试环境稳定性提升实践
查看>>
websocket搭建简单的网页聊天室框架【续1】
查看>>
Scrapy Shell
查看>>
array_merge和+号合并数组的区别
查看>>
TP5整合 WorkerMan 以及 GatewayWorker
查看>>
Facebook Docusaurus 中文文档 准备网站
查看>>
如何绘制一个圆圆的loading圈
查看>>
Nodejs学习记录:用koa.js开发微信公众号
查看>>
Android源码集锦,悬浮窗综合资讯类APP动画效果左右切换效果美妆领域
查看>>
Spring Cloud(六)服务网关 zuul 快速入门
查看>>
d3.js中动态数据的请求、处理及使用
查看>>
Vue源码解析(六)-vue-router
查看>>