宏定义的macro究竟支持空格不

宏定义的macro到底支持空格不?
#define MEAN(x, y) (x + y) / 2  //compiled in code::block
int main (void)
{
printf ("%d\n", MEAN (1, 3));  //print: 2
return 0;
}

书上说宏名字中不允许有空格,但上面这段程序没有任何错误。
是说函数宏支持空格,但对象宏不支持?

------解决方案--------------------
#define identifier token-sequence

不带参数的宏,identifier前后的空格都会被丢弃。
#define identifier( identifier-list ) token-sequence

带参数的宏,第一个identifier和'('之间不能有空格,不然就会被解释成第一种。
------解决方案--------------------
引用:
Quote: 引用:

#define identifier token-sequence

不带参数的宏,identifier前后的空格都会被丢弃。
#define identifier( identifier-list ) token-sequence

带参数的宏,第一个identifier和'('之间不能有空格,不然就会被解释成第一种。

你这个倒是一针见血。
可否再追问下,函数宏对括号处理的过程是怎么样的?
另外,有没有直观的办法看到宏展开后的c代码?还是只能像目前这样推测?


<<The C Programming Language>> 2nd Edition
When a macro has been defined in the second form(with parameters), subsequent textual instances of the macro identifier followed by optional white space, and then by (, a sequence of tokens separated by commas, and a ) constitute a call of the macro.

standard C 98/99
不带参数的宏是object-like macro,带参数的是function-like macro
宏定义里跟在宏名后面的lparen(左括号)是一个预处理token,引出后面的替换列表,右括号用来结束替换列表,中间插入的成对括号会被忽略。

引用





------解决方案--------------------
。。按错了,接着上面。
引用一下原文,以防因为英语水平差误导楼主。。。

A preprocessing directive of the form

# define identifier lparen identifier-list_opt ) replacement-list new-line
# define identifier lparen ... ) replacement new-line