3 // side test verifies multiple rounds of argument expansion
4 #define bear SecondExpansion
7 int mmmA(mmmB); // mmmB -> bear, and then in mmmA(), bear -> SecondExpansion
9 // pasting skips the first round of expansion
10 #define mmcatmmdog PostPasteExpansion
13 #define mmp(a,b) a## b
14 int mmp(mmcat, mmdog); // mmcat/mmdog not expanded, mmcatmmdog -> PostPasteExpansion
17 #define mmtokpastepre(a) a##27
18 mmtokpastepre(float foo); // should declare "float foo27;"
21 #define mmtokpastepost(a) uni ##a
22 mmtokpastepost(form float foo155); // should declare "uniform float foo155;"
25 #define foo ShouldntExpandToThis
27 #define bothpaste(a,b) a##b
28 float bothpaste(foo, 719); // should declare "float foo719;"
29 #define secpaste(a,b) a bar ## b
30 secpaste(uniform float, foo semi) // should declare "uniform float barfoo;"
43 #define multiPaste(a, b, c) a##or##b flo##at foo##c
44 multiPaste(unif, m, 875);
47 #define simplePaste(a,b) a##b
48 // 1020 + 5 characters
49 float simplePaste(ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF012345, 12345);
52 int a = simplePaste(11,12);
54 // should work in #if as well
57 #define marine_animal(suffix) (sea ## suffix)
59 #if marine_animal(horse) // should pass
60 uniform float seahorse_var;
62 #if !marine_animal(lion) // should pass
63 uniform float sealion_var;
67 #define MAKE_OP(L, R) L ## R
\r
70 int cop = aop MAKE_OP(<, <) bop;
\r
71 bool dop = aop MAKE_OP(!,=) bop;
\r
73 #define MAKE_OP3(L, M, R) L ## M ## R
\r
78 e MAKE_OP3(>,>,=) 2;
\r
80 // recovery from bad op
\r
81 bool f = e MAKE_OP(>,!) 5;
\r
84 // arguments: should make 'uniform int argPaste2;'
85 #define M_NEST(q) int q
\r
86 #define M_OUTER(p) M_NEST(p##2)
\r
87 uniform M_OUTER(argPaste);
\r
88 // should make 'uniform int argPaste20suff;'
\r
89 #define M_NEST2(q) int q ## suff
\r
90 #define M_OUTER2(p) M_NEST2(p ## 20)
\r
91 uniform M_OUTER2(argPaste);
\r
97 #define baz bax(/##)
\r