3 ms·
There are some more examples: • In the stringification via `#`, whitespaces are significant but any run will be converted to a single canonical space character
by lifthrasiir 3y ago
There are some more examples:
• In the stringification via `#`, whitespaces are significant but any run will be converted to a single canonical space character.
• Macros can only be redefined when conflicting definitions are identical, where all whitespace separations are considered identical and trailing whitespaces are ignored. So you can put multiple copies of `#define FOO 3 + 4` with differing number of whitespaces, but `#define FOO 3+4` is not considered identical.
> Similarly, `1 1` is not the same as `11`, `0x 1` is not `0x1`, and `0. 0` is not `0.0`.
There is some interesting surprise here because the tokenization specifically looks for the preprocessing number (the `pp-number` non-terminal), which is a superset of both integers and floating points. There exist a set of preprocessing-only numerals, like `0xe+4`, which would be a syntax error once got past the preprocessor.
> Spaces are significant in escape sequences as well - "\n" is different from "\ n".
This is most visible when the space is between `\` and a newline. GCC and Clang accepts this as an extension but will issue the "backslash and newline separated by space" warning.
> Before C23, sequences like `??/` (but not `? ? /`) were alternative ways of spelling many other characters.
Note that digraphs (`%>` here) are still allowed. Trigraphs were problematic as they were very early textual replacements (even earlier than the tokenization!), while digraphs are just separate tokens with the same semantics.