当前位置:网站首页>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;
边栏推荐
- 【Unity入门计划】制作RubyAdventure01-玩家的创建&移动
- How much do you know about the intelligent operation and maintenance service of data warehouse based on DMS?
- 13、OOM模拟
- 详谈RDMA技术原理和三种实现方式
- [QT] Qt project demo: data is displayed on the ui interface, double-click the mouse to display specific information in a pop-up window
- 小熊派——无线联网开发
- 滑环安装注意事项
- 请问下阿里云全托管flink能执行两条flink sql命令么?
- "Avnet Embedded Weekly" Issue 276: 2022.07.25--2022.07.31
- 全新探险者以40万的产品击穿豪华SUV价格壁垒
猜你喜欢

如何使用MATLAB绘制极坐标堆叠柱状图

MySQL性能优化_小表驱动大表

基于DMS的数仓智能运维服务,知多少?

QT QT 】 【 to have developed a good program for packaging into a dynamic library

MPLS的wpn实验

【Unity入门计划】基本概念(8)-瓦片地图 TileMap 01

【Unity入门计划】基本概念(7)-Input Manager&Input类

为什么我强烈推荐使用智能化async?

Introduction to the advantages of the new generation mesh network protocol T-Mesh wireless communication technology

使用 PowerShell 将 Windows 转发事件导入 SQL Server
随机推荐
smp,numa和mpp体系结构总结
protobuf 中数据编码规则
Cookie和Session的关系
leetcode:187. 重复的DNA序列
mysql delete execution error: You can't specify target table 'doctor_info' for update in FROM clause
用友YonSuite与旺店通数据集成对接-技术篇2
使用Make/CMake编译ARM裸机程序(基于HT32F52352 Cortex-M0+)
【QT】Qt项目demo:数据在ui界面上显示,鼠标双击可弹窗显示具体信息
[QT] Qt project demo: data is displayed on the ui interface, double-click the mouse to display specific information in a pop-up window
Analysis of ffplay video playback principle
vector类
C语言02、语句、函数
STM32 GPIO LED和蜂鸣器实现【第四天】
基于DMS的数仓智能运维服务,知多少?
MySQL窗口函数 OVER()函数介绍
Common distributed theories (CAP, BASE) and consensus protocols (Gosssip, Raft)
[微信小程序开发者工具] × #initialize
Interpretation of the 2021 Cost of Data Breach Report
Kubernetes 笔记 / 生产环境
Research on power flow in DC microgrid based on Newton's method (Matlab code implementation)