当前位置:网站首页>C陷阱与缺陷 第6章 预处理器 6.1 不能忽视宏定义中的空格
C陷阱与缺陷 第6章 预处理器 6.1 不能忽视宏定义中的空格
2022-07-30 17:10:00 【weixin_客子光阴】
不能忽视宏定义中的空格
一个宏如果不带参数,则只需要使用宏名即可,括号无关紧要。预处理器从宏定义中就可以知道宏调用时是否需要参数。
与宏调用相比,宏定义显得有些“暗藏机关”。例如,下面的宏定义中f是否带了一个参数呢?
#define f (x) ((x) - 1)
答案只可能有两种:f(x)或者代表
((x) - 1)
或者代表
(x) ((x) - 1)
第二个答案是正确的,因为在f和后面的(x)之间多了一个空格!所以,如果希望定义f(x)为((x)-1),
必须像下面这样写:
#define f(x) ((x) - 1)
这一规则不适用于宏调用,而只适用于宏定义。因此,在上面完成宏定义后,f(3)与f (3)求值后都等于2。
边栏推荐
- 阿里SIM-基于检索的用户行为兴趣CTR模型(Search-based user Interest Model(SIM))
- ERROR 2003 (HY000) Can‘t connect to MySQL server on ‘localhost3306‘ (10061)解决办法
- C语言向MySQL插入数据
- Discuz magazine/news report template (jeavi_line) UTF8-GBK template
- JMeter Notes 4 | JMeter Interface Introduction
- Deep Feedback Network for Recommendation
- Weka 3.8.6安装与Weka 3.8.6功能介绍
- Graph Attention Mechanism
- No qualifying bean of type问题解决
- Promise入门到精通(1.5w字详解)
猜你喜欢

Tensorflow中实现正则化

实现web实时消息推送的7种方案

LeetCode318:单词长度的最大乘积

ERROR 2003 (HY000) Can't connect to MySQL server on 'localhost3306' (10061)Solution

浅谈在线编辑器中增量编译技术的应用

onenote使用

有没有并发系统设计的经验,我该怎么说?

Tensorflow模型量化(Quantization)原理及其实现方法

疫情之下的裁员浪潮,7点建议帮你斩获心仪offer

Error occurred while trying to proxy request The project suddenly can't get up
随机推荐
Promise entry to proficient (1.5w word detailed explanation)
[NCTF2019]Fake XML cookbook-1|XXE漏洞|XXE信息介绍
[HarekazeCTF2019]Avatar Uploader 1
Discuz magazine/news report template (jeavi_line) UTF8-GBK template
向量检索基础方法总结
Valid bracketed strings [greedy exercise]
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.
C# 跨程序传图(共享内存块传图)跨exe传图
Express framework connects MySQL and ORM framework
【云商店公告】关于7月30日帮助中心更新通知
gvim命令记录
Explore CSAPP Experiment 2-bomb lab-Section 1
Deep Feedback Network for Recommendation
Mongoose module
Login Module Debugging - Getting Started with Software Debugging
What does a good resume look like in the eyes of a big factory interviewer?
腾讯专家献上技术干货,带你一览腾讯广告召回系统的演进
592. Fraction Addition and Subtraction
基于stm32的shell实现
Test Management and Specification