当前位置:网站首页>C专家编程 第3章 分析C语言的声明 3.6 typedef int x[10]和#define x int[10]的区别
C专家编程 第3章 分析C语言的声明 3.6 typedef int x[10]和#define x int[10]的区别
2022-08-03 16:09:00 【weixin_客子光阴】
3.6 typedef int x[10]和#define x int[10]的区别
/*typedef看成是一种彻底的“封装”类型----在声明它之后不能再往里面增加别的
*内容,可以用其他类型说明符对宏类型名进行扩展,但对typedef所定义的类型却不能那样做
*/
#define peach int
unsigned peach i; /*没问题*/
typedef int banana;
unsigned banana i; /*错误!非法*/
/*在几个连续的变量的声明中,用typedef定义的类型能够保证声明中所有的变量均为
*同一种类型,而用#define定义的类型却无法保证
*/
#define int_ptr int *
int_ptr chalk, cheese;
相当于
int *chalk, cheese;
typedef char * char_ptr;
char_ptr Bentley, Rolls_Royce;
相当于
char * Bentley, *Rolls_Royce;
边栏推荐
- Tolstoy: There are only two misfortunes in life
- 技术干货|如何将 Pulsar 数据快速且无缝接入 Apache Doris
- 托尔斯泰:生活中只有两种不幸
- Difference and performance comparison between HAL and LL library of STM32
- QT QT 】 【 to have developed a good program for packaging into a dynamic library
- STM32的HAL和LL库区别和性能对比
- "Avnet Embedded Weekly" Issue 276: 2022.07.25--2022.07.31
- 我在滴滴做开源
- Not to be ignored!Features and advantages of outdoor LED display
- 土耳其国防部:联合协调中心将对首艘乌克兰粮船进行安全检查
猜你喜欢
随机推荐
Small Tools(4) 整合Seata1.5.2分布式事务
详谈RDMA技术原理和三种实现方式
【带你了解SDN和网络虚拟化】
MarkDown常用代码片段和工具
如何启动 NFT 集合
破解数字化转型困局,企业分析协同场景案例解析
MySQL性能优化_小表驱动大表
AI+BI+可视化,Sugar BI架构深度剖析
Research on power flow in DC microgrid based on Newton's method (Matlab code implementation)
字典表(还需要输入2个字)
STM32 GPIO LED and buzzer implementation [Day 4]
mysql delete execution error: You can't specify target table 'doctor_info' for update in FROM clause
JD6606SP5_JD6606SSP_JD6606SASP_JD6621W7百盛新纪元授权代理商
Yuan xiaolin: Volvo focus on travel security, and put it perfectly
13 and OOM simulation
I am doing open source in Didi
leetcode:187. 重复的DNA序列
STM32的HAL和LL库区别和性能对比
基于DMS的数仓智能运维服务,知多少?
从零开始搭建MySQL主从复制架构








