首先,宏里的参数表是不能替换的
============
#define B A+C
#define C B+A
#define A B+C
A;
============
#define B A+C
#define C B+A
#define A B+C
B+C;
============
#define B A+C
#define C B+A
#define A B+C
A+C+B+A;
============
#define B A+C
#define C B+A
#define A B+C
A+B+A+A+C+A;
============
标准里有这么写:
If the name of the macro being replaced is found during this scan of the replacement list
(not including the rest of the source file’s preprocessing tokens), it is not replaced.
Furthermore, if any nested replacements encounter the name of the macro being replaced,
it is not replaced. These nonreplaced macro name preprocessing tokens are no longer
available for further replacement even if they are later (re)examined in contexts in which
that macro name preprocessing token would otherwise have been replaced.
也就是说只能替换一次,在第三步里虽然又出现了A,但它是不可替换的
最初由 Rinrin 发布 首先,宏里的参数表是不能替换的 ============ If the name of the macro being replaced is found during this scan of the replacement list (not including the rest of the source file’s preprocessing tokens), it is not replaced. Furthermore, if any nested replacements encounter the name of the macro being replaced, it is not replaced. These nonreplaced macro name preprocessing tokens are no longer available for further replacement even if they are later (re)examined in contexts in which that macro name preprocessing token would otherwise have been replaced.