当前位置:网站首页>C陷阱与缺陷 第6章 预处理器 6.4 宏并不是类型定义
C陷阱与缺陷 第6章 预处理器 6.4 宏并不是类型定义
2022-07-30 17:10:00 【weixin_客子光阴】
宏不是类型定义
宏的一个常见用途是,使多个不同变量的类型可在一个地方说明:
#define FOOTYPE struct foo
FOOTYPE a;
FOOTYPE b, c;
这样,编程人员只需在程序中改动一行代码,即可改变a,b,c的类型,而与a,b,c在程序的什么地方声明无关。
宏定义的这种用法有一个优点---可移植性,得到了所有C编译器的支持。
但是,我们最好还是使用类型定义:
typedef struct foo FOOTYPE;
这个语句为FOOTYPE为一个新的类型,与struct foo完全等效。
使用typedef的方式更通用一些。
#define T1 struct foo *
typedef struct foo *T2;
T1 a, b;
T2 c, d;
第一个声明被扩展为:
struct foo *a, b;
第二个声明被扩展为:
struct foo *c, *d;
边栏推荐
- MySQL超详细安装教程 手把手教你安装MySQL到使用MySQL 最简单的MySQL安装方式,这种方式装,卸载也简单
- 优酷视频元素内容召回系统:多级多模态引擎探索
- Tensorflow模型量化(Quantization)原理及其实现方法
- Express framework connects MySQL and ORM framework
- Mongoose模块
- Chapter 6: Decisive Autumn Moves
- 全球架构师峰会
- Mysql进阶优化篇01——四万字详解数据库性能分析工具(深入、全面、详细,收藏备用)
- LeetCode167:有序数组两数之和
- 【综合类型第 34 篇】喜讯!喜讯!!喜讯!!!,我在 CSDN 的第一个实体铭牌
猜你喜欢

牛客网刷题——运算符问题

Analysis and Simulation of Short Circuit Fault in Power System Based on MATLAB

LeetCode167:有序数组两数之和

Is it reliable to work full-time in self-media?

云厂商做生态需要“真连接、真赋能”,用“技术+真金实银”发展伙伴

LeetCode167: Sum of two numbers in sorted array

Oracle动态监听与静态监听详解

论文阅读之《DeepIlluminance: Contextual IlluminanceEstimation via Deep Neural Networks》

Win11如何把d盘空间分给c盘?Win11d盘分盘出来给c盘的方法

Shell implementation based on stm32
随机推荐
KDD‘21推荐系统离散特征表征无embedding table Learning to Embed Categorical Features without Embedding Tables for
Mongoose模块
torch.optim.Adam() function usage
Weka 3.8.6安装与Weka 3.8.6功能介绍
web服务通过用户访问请求判断设备来源
LeetCode167: Sum of two numbers in sorted array
将 APACHE 日志解析到 SQL 数据库中
主流的深度学习推理架构有哪些呢?
万华化学精细化工创新产品大会
FP6606ACAW4 TQFN-20L (3mmx3mm) USB双端口充电控制器 百盛电子代理
MySQL详细学习教程(建议收藏)
Test Management and Specification
论文阅读之《DeepIlluminance: Contextual IlluminanceEstimation via Deep Neural Networks》
The first time I used debug query and found that this was empty, does it mean that the database has not been obtained yet?please help.
Win11如何把d盘空间分给c盘?Win11d盘分盘出来给c盘的方法
Servo System of Hydraulic Steering Gear Based on Fuzzy PID
Chapter 5 Advanced SQL Processing
[极客大挑战 2020]Roamphp1-Welcome
Discuz magazine/news report template (jeavi_line) UTF8-GBK template
优酷视频元素内容召回系统:多级多模态引擎探索