Reputation: 4383
Normally, via the standards, any \ followed directly by a newline is converted into the code without the newline and backslash. For example:
int yams\
yams;
turns into
int yamsyams;
and
int cheese // blerg \
more blerg
turns into
int cheese // blerg more blerg
This behavior can be nice with very long single line code.
However, it seems that
#\
This code not part of the macro
While
#a\
This code is part of the macro.
And even
# \
This code is not part of the macro
While
# a\
This code is part of the macro
Why is this the one exception to the "\ newline" being removed rule?
Upvotes: 4
Views: 570
Reputation: 171303
As described in [lex.phases], replacing the backslash-newline is done by the preprocessor, and should happen very early, in phase 2, which is before splitting the source into preprocessor tokens (phase 3) and before handling preprocessor directives such as #define
or #include
(phase 4).
So in all your examples you should see the backslash-newline removed.
Upvotes: 3