如果要实现 while 循环,则需要在预处理器中使用递归。执行递归的最简单方法是使用延迟表达式。延迟表达式是一种需要更多扫描才能完全展开的表达式:
#define EMPTY()
#define DEFER(id) id EMPTY()
#define OBSTRUCT(id) id DEFER(EMPTY)()
#define EXPAND(...) __VA_ARGS__
#define A() 123
A() // Expands to 123
DEFER(A)() // Expands to A () because it requires one more scan to fully expand
EXPAND(DEFER(A)()) // Expands to 123, because the EXPAND macro forces another scan