summaryrefslogtreecommitdiff
path: root/05/tests
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2022-02-18 12:36:57 -0500
committerpommicket <pommicket@gmail.com>2022-02-18 12:36:57 -0500
commit826d1afd58c2e064a9c8fdb09eda1b08469de1a8 (patch)
treeb4fedc589a1944f6cf3f451a9db976b431e89b25 /05/tests
parentc42c5d94b8944e19cd17a5b540e4c70013c62b92 (diff)
newer version of tcc almost working
Diffstat (limited to '05/tests')
-rw-r--r--05/tests/macros.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/05/tests/macros.c b/05/tests/macros.c
new file mode 100644
index 0000000..688c45e
--- /dev/null
+++ b/05/tests/macros.c
@@ -0,0 +1,40 @@
+ #define x 3
+ #define f(a) f(x * (a))
+ #undef x
+ #define x 2
+ #define g f
+ #define z z[0]
+ #define h g(~
+ #define m(a) a(w)
+ #define w 0,1
+ #define t(a) a
+
+ f(y+1) + f(f(z)) % t(t(g)(0) + t)(1);
+ g(x+(3,4)-w) | h 5) & m(f)^m(m);
+
+ #undef x
+ #undef g
+ #undef z
+ #undef h
+ #undef m
+ #undef w
+ #undef t
+ #undef f
+
+#define str(s) # s
+ #define xstr(s) str(s)
+ #define debug(s, t) printf("x" # s "= %d, x" # t "= %s", \
+ x ## s, x ## t)
+ #define INCFILE(n) vers ## n /* from previous #include example */
+ #define glue(a, b) a ## b
+ #define xglue(a, b) glue(a, b)
+ #define HIGHLOW "hello"
+ #define LOW LOW ", world"
+
+ debug(1, 2);
+ fputs(str(strncmp("abc\0d", "abc", '\4') /* this goes away */
+ == 0) str(: @\n), s);
+ include xstr(INCFILE(2).h)
+ glue(HIGH, LOW);
+ xglue(HIGH, LOW)
+