This snippet is mostly from the Cloak wiki, C Preprocessor tricks, tips and idioms, with DEFER2, X1, and X2 added by me for ease of referencing things in this post.
#define EMPTY()
#define DEFER(id) id EMPTY()
#define DEFER2(id) id
#define A() 123
X1 = DEFER(A)() // Expands to A () because it requires one more scan to fully expand
X2 = DEFER2(A)()
Result of preprocessing:
X1 = A ()
X2 = 123
The explanation given in the same wiki is,
...when a macro is scanned and expanding, it creates a disabling context. This disabling context will cause a token, that refers to the currently expanding macro, to be painted blue. Thus, once its painted blue, the macro will no longer expand. This is why macros don't expand recursively. However, a disabling context only exists during one scan, so by deferring an expansion we can prevent our macros from becoming painted blue.
I'm unable to understand why EMPTY() in the body of DEFER should result in any deferring.
DEFER(A)()
// A EMPTY()()
// A () <--- the preprocessor stops here, for some reason!
// 123
If A() would expand to 123 in the DEFER2 case, why should the preprocessor stop expanding A () in the DEFER case? Why is A considered part of the disabling context in case of DEFER but not in that of DEFER2?
I have also consulted the The C Preprocessor GNU reference, section Macro Pitfalls but still no clue.