我很好奇,在 C/C++ 中,#
是什么意思?
例如,#if
。它叫做“hashtag if”吗?
最佳答案
源代码中以#if
开头的行称为preprocessor directive如今。在 The C Programming Language ("K&R")1 一书中,它被称为“编译器控制线”。
#
这个符号本身好像没有什么特别的名字。例如,documentation for the gcc compiler只是称它为“#”:
Preprocessing directives are lines in your program that start with ‘#’. Whitespace is allowed before and after the ‘#’. The ‘#’ is followed by an identifier, the directive name. It specifies the operation to perform. Directives are commonly referred to as ‘#name’ where name is the directive name. For example, ‘#define’ is the directive that defines a macro.
K&R 书中也只是称其为“#”:
Lines beginning with # communicate with this preprocessor.
1 丹尼斯·里奇,布赖恩·科尼汉; C 程序设计语言,第 1 版(1978 年); p. 207
https://stackoverflow.com/questions/66548702/