1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
line = __LINE__
file = __FILE__
#define A a /* a defined */
#define B b /* b defined */
#define C c /* c defined */
#define EXPAND(x) x
EXPAND(a) -> a
EXPAND(A) -> a
#define _STRINGIFY(x) #x
_STRINGIFY(A) -> "A"
#define STRINGIFY(x) _STRINGIFY(x)
STRINGIFY(b) -> "b"
STRINGIFY(A) -> "a"
#define _CONCAT(x, y) x ## y
_CONCAT(A, B) -> AB
#define A_CONCAT done_a_concat
_CONCAT(A, _CONCAT(B, C)) -> done_a_concat(b, c)
#define CONCAT(x, y) _CONCAT(x, y)
CONCAT(A, CONCAT(B, C)) -> abc
#define _CONCAT3(x, y, z) x ## y ## z
_CONCAT3(a, b, c) -> abc
_CONCAT3(A, B, C) -> ABC
_CONCAT3(A, EXPAND(B), C) -> AEXPAND(b)C
Line is __LINE__
File is __FILE__
#define two three
one /* one */
#define one two
one /* three */
#undef two
#define two five
one /* five */
#undef two
one /* two */
#undef one
#define one four
one /* four */
#undef one
#define one one
one /* one */
/* warning line 57 column 0 */
#warning arse
#define foo(x) foo(x, b)
foo(1) -> _foo(1, b) without the _
foo(foo(2)) -> _foo(_foo(2, b), b) without the _
// foo(y, z)
#define var(x...) a x b
var(e, f, g) -> a e, f, g b
|