简体   繁体   English

宏定义中的空#是什么意思?

[英]What does an empty # mean in a macro definition?

I have the following macro: 我有以下宏:

#define F(Args, ...) \
   // macro definition
#
   F(()) // looks like usage?
#undef F

What does the line containing only # mean? 该行只包含#是什么意思? Is F(()) a usage of the macro? F(())是宏的用法吗?

Technically, that's not part of the macro (no continuation line before it). 从技术上讲,这不是宏的一部分(之前没有延续线)。 It's a directive that comes after the #define directive. 它是#define指令之后的指令。

# on its own line is called a null directive and it does nothing (as good as a comment). #在它自己的行上称为空指令 ,它什么都不做(和注释一样好)。

It's no longer practically useful (except as a visual marker) but in prehistoric C, the preprocessor only got invoked if a C source file started with a directive and the null directive placed at the very beginning of a C file was a good way to make sure the file was preprocessed (ie, that later directives worked) without starting with a concrete directive. 它不再具有实际用途(除了作为可视标记),但在史前C中,如果C源文件以指令开始并且在C文件的最开头放置的null指令是一个很好的方法,则只调用预处理器确保文件已经过预处理(即后来的指令有效),而无需从具体指令开始。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM