From 45591bc221bb8268567acdaa523cbac94d31a90e Mon Sep 17 00:00:00 2001 From: lemon Date: Wed, 10 Sep 2025 11:19:16 +0200 Subject: lex: implement basic function-like macro functionality --- test/pp.c | 3 +-- test/pp.h | 12 ++++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'test') diff --git a/test/pp.c b/test/pp.c index ee4b98a..2e6193e 100644 --- a/test/pp.c +++ b/test/pp.c @@ -5,6 +5,5 @@ int main(void) { - hi(); - return Foo + Bar; + hi(ADD(Foo, SQR(Bar+1))); } diff --git a/test/pp.h b/test/pp.h index 80042fd..e914800 100644 --- a/test/pp.h +++ b/test/pp.h @@ -3,12 +3,16 @@ extern warnhere(); #define Foo 9 -void hi() { - extern int printf(); - printf("hi from header\n"); +void hi(int x) { + extern int printf(const char *, ...); + printf("hi from header ;%d\n", x); } - +#if 1 +#endif #elifndef Ww #define Bar 7 +#define SQR_(x) (x)*(x) +#define SQR(y) SQR_(y) +#define ADD(a,b) (a)+(b) #endif -- cgit v1.2.3