tmp/tmp609oece7/{from.md → to.md}
RENAMED
|
@@ -23,10 +23,58 @@ is not a valid preprocessing token, the behavior is undefined. The
|
|
| 23 |
resulting token is available for further macro replacement. The order of
|
| 24 |
evaluation of `##` operators is unspecified.
|
| 25 |
|
| 26 |
[*Example 1*:
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
In the following fragment:
|
| 29 |
|
| 30 |
``` cpp
|
| 31 |
#define hash_hash # ## #
|
| 32 |
#define mkstr(a) # a
|
|
@@ -49,5 +97,25 @@ In other words, expanding `hash_hash` produces a new token, consisting
|
|
| 49 |
of two adjacent sharp signs, but this new token is not the `##`
|
| 50 |
operator.
|
| 51 |
|
| 52 |
— *end example*]
|
| 53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
resulting token is available for further macro replacement. The order of
|
| 24 |
evaluation of `##` operators is unspecified.
|
| 25 |
|
| 26 |
[*Example 1*:
|
| 27 |
|
| 28 |
+
The sequence
|
| 29 |
+
|
| 30 |
+
``` cpp
|
| 31 |
+
#define str(s) # s
|
| 32 |
+
#define xstr(s) str(s)
|
| 33 |
+
#define debug(s, t) printf("x" # s "= %d, x" # t "= %s", \
|
| 34 |
+
x ## s, x ## t)
|
| 35 |
+
#define INCFILE(n) vers ## n
|
| 36 |
+
#define glue(a, b) a ## b
|
| 37 |
+
#define xglue(a, b) glue(a, b)
|
| 38 |
+
#define HIGHLOW "hello"
|
| 39 |
+
#define LOW LOW ", world"
|
| 40 |
+
|
| 41 |
+
debug(1, 2);
|
| 42 |
+
fputs(str(strncmp("abc\0d", "abc", '\4') // this goes away
|
| 43 |
+
== 0) str(: \@n), s);
|
| 44 |
+
#include xstr(INCFILE(2).h)
|
| 45 |
+
glue(HIGH, LOW);
|
| 46 |
+
xglue(HIGH, LOW)
|
| 47 |
+
```
|
| 48 |
+
|
| 49 |
+
results in
|
| 50 |
+
|
| 51 |
+
``` cpp
|
| 52 |
+
printf("x" "1" "= %d, x" "2" "= %s", x1, x2);
|
| 53 |
+
fputs("strncmp(\"abc\\0d\", \"abc\", '\\4') == 0" ": \@n", s);
|
| 54 |
+
#include "vers2.h" (after macro replacement, before file access)
|
| 55 |
+
"hello";
|
| 56 |
+
"hello" ", world"
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
or, after concatenation of the character string literals,
|
| 60 |
+
|
| 61 |
+
``` cpp
|
| 62 |
+
printf("x1= %d, x2= %s", x1, x2);
|
| 63 |
+
fputs("strncmp(\"abc\\0d\", \"abc\", '\\4') == 0: \@n", s);
|
| 64 |
+
#include "vers2.h" (after macro replacement, before file access)
|
| 65 |
+
"hello";
|
| 66 |
+
"hello, world"
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
Space around the `#` and `##` tokens in the macro definition is
|
| 70 |
+
optional.
|
| 71 |
+
|
| 72 |
+
— *end example*]
|
| 73 |
+
|
| 74 |
+
[*Example 2*:
|
| 75 |
+
|
| 76 |
In the following fragment:
|
| 77 |
|
| 78 |
``` cpp
|
| 79 |
#define hash_hash # ## #
|
| 80 |
#define mkstr(a) # a
|
|
|
|
| 97 |
of two adjacent sharp signs, but this new token is not the `##`
|
| 98 |
operator.
|
| 99 |
|
| 100 |
— *end example*]
|
| 101 |
|
| 102 |
+
[*Example 3*:
|
| 103 |
+
|
| 104 |
+
To illustrate the rules for placemarker preprocessing tokens, the
|
| 105 |
+
sequence
|
| 106 |
+
|
| 107 |
+
``` cpp
|
| 108 |
+
#define t(x,y,z) x ## y ## z
|
| 109 |
+
int j[] = { t(1,2,3), t(,4,5), t(6,,7), t(8,9,),
|
| 110 |
+
t(10,,), t(,11,), t(,,12), t(,,) };
|
| 111 |
+
```
|
| 112 |
+
|
| 113 |
+
results in
|
| 114 |
+
|
| 115 |
+
``` cpp
|
| 116 |
+
int j[] = { 123, 45, 67, 89,
|
| 117 |
+
10, 11, 12, };
|
| 118 |
+
```
|
| 119 |
+
|
| 120 |
+
— *end example*]
|
| 121 |
+
|