宏 [英] macros
问题描述
嗨
任何人都可以解释为什么输出以下代码:
#define A 1
#define B 2
AB
仅在预处理后,是:
1。 2
为什么预处理器在每个字符之间放置空格,当
宏调用没有?
此致,B
bo *******@gmail.com 写道:
嗨
任何人都可以解释为什么以下代码的输出:
#define A 1
#define B 2
AB
是:
1。 2
为什么预处理器在每个字符之间放置空格,当
宏调用没有?
预处理器经常 - 并且不正确地 - 被称为
对程序源代码的文本进行操作。实际上,
它对令牌(正式地,预处理令牌)
进行操作,这些令牌来自文本。这些代币只是一个接一个地来了,漂亮的女佣一个接一个地来了;他们这样做
不需要用空格分隔。同样地,他们
并没有神奇地相互结合只是因为他们
恰好相邻。
所以:当示例代码到达预处理器时,
它被分为三个令牌,我们可以将其表示为
A
bo*******@gmail.com 写道:
>
任何人都可以解释为什么输出以下代码:
#define A 1
#define B 2
AB
仅在预处理后,是:
1。 2
为什么预处理器在每个字符之间放置空格,当
宏调用没有?
因为这是由C标准指定的。作为一个纯粹实用的
问题,它将单个单词分隔为宏。
-
Chuck F(cinefalconer at maineline dot net)
适用于咨询/临时嵌入式和系统。
< http://cbfalconer.home.att.net>
-
通过 http://www.teranews的免费Usenet帐户发布.com
bo *** **** @gmail.com 写道:
>
嗨
任何人都可以解释为什么输出以下代码:
#define A 1
#define B 2
AB
仅在预处理后,是:
1。 2
为什么预处理器在每个字符之间放置空格,当
宏调用没有?
为什么你在A和B之间放一个点?
AB应该是什么意思?
< br $> b $ b -
pete
Hi
Can anyone explain why the output of the following code:
#define A 1
#define B 2
A.B
after preprocessing only, is:
1 . 2
Why does the preprocessor put spaces between each character, when the
macro invocation has none?
Regards, B
bo*******@gmail.com wrote:Hi
Can anyone explain why the output of the following code:
#define A 1
#define B 2
A.B
after preprocessing only, is:
1 . 2
Why does the preprocessor put spaces between each character, when the
macro invocation has none?The preprocessor is often -- and incorrectly -- said to
operate on the text of the program''s source code. In fact,
it operates on tokens (formally, "preprocessing tokens")
that have been derived from the text. These tokens simply
come one after another, pretty maids all in a row; they do
not need to be separated by spaces. Equally, though, they
do not magically combine with each other just because they
happen to be adjacent.
So: By the time the sample code reaches the preprocessor,
it has been divided into three tokens which we may represent as
A
bo*******@gmail.com wrote:>
Can anyone explain why the output of the following code:
#define A 1
#define B 2
A.B
after preprocessing only, is:
1 . 2
Why does the preprocessor put spaces between each character, when
the macro invocation has none?Because that is specified by the C standard. As a purely practical
matter, it keeps individual words separated in macros.
--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
--
Posted via a free Usenet account from http://www.teranews.com
bo*******@gmail.com wrote:>
Hi
Can anyone explain why the output of the following code:
#define A 1
#define B 2
A.B
after preprocessing only, is:
1 . 2
Why does the preprocessor put spaces between each character, when the
macro invocation has none?Why did you put a dot in between A and B?
What should AB mean?
--
pete
这篇关于宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!