If a macro definition contains x ## ## and x is a parameter and the macro is called with an empty argument, then clang ignores the x ## when expanding the macro, leaving just ##. It then tries to paste ## after the preceding token!
To avoid confusion, let paste be a ## token in an odd numbered position in a sequence of ## tokens, and let hashhash be a ## token in an even numbered position in a sequence of ## tokens.
In most cases, clang treats hashhash as an ordinary token, not as a paste operator.
But if x is a parameter for an empty argument, foo x ## bar foo x ## ## bar foo x ## ## ## bar is expanded to foo bar foo ## bar foo ## ## bar. clang interprets this as foo bar foopastebar foohashhashbar. The result output is foo bar foobar foo ## bar.
If a macro definition contains `x ## ##` and `x` is a parameter and the macro is called with an empty argument, then clang ignores the `x ##` when expanding the macro, leaving just `##`. It then tries to paste `##` after the preceding token!
To avoid confusion, let **paste** be a ## token in an odd numbered position in a sequence of ## tokens, and let **hashhash** be a ## token in an even numbered position in a sequence of ## tokens.
In most cases, clang treats **hashhash** as an ordinary token, not as a paste operator.
But if `x` is a parameter for an empty argument, `foo x ## bar foo x ## ## bar foo x ## ## ## bar ` is expanded to `foo bar foo ## bar foo ## ## bar`. clang interprets this as `foo bar foo `**paste**` bar foo `**hashhash**` bar`. The result output is `foo bar foobar foo ## bar`.
If a macro definition contains
x ## ##
andx
is a parameter and the macro is called with an empty argument, then clang ignores thex ##
when expanding the macro, leaving just##
. It then tries to paste##
after the preceding token! To avoid confusion, let paste be a ## token in an odd numbered position in a sequence of ## tokens, and let hashhash be a ## token in an even numbered position in a sequence of ## tokens. In most cases, clang treats hashhash as an ordinary token, not as a paste operator. But ifx
is a parameter for an empty argument,foo x ## bar foo x ## ## bar foo x ## ## ## bar
is expanded tofoo bar foo ## bar foo ## ## bar
. clang interprets this asfoo bar foo
pastebar foo
hashhashbar
. The result output isfoo bar foobar foo ## bar
.