From 4e9020dfb847d80475415f9f5914efaa50238767 Mon Sep 17 00:00:00 2001 From: lemon Date: Mon, 23 Feb 2026 20:33:42 +0100 Subject: cpp: add __COUNTER__ macro --- test/07-pp.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test') diff --git a/test/07-pp.c b/test/07-pp.c index b1afa17..be1dfe0 100644 --- a/test/07-pp.c +++ b/test/07-pp.c @@ -7,6 +7,8 @@ join: "x ## y" wide L"abc123 猫,€á💫", U+1f98b Output ends here ok ... +11 +11 */ #include "07-pp.h" @@ -62,6 +64,11 @@ static void f(void) { (void)strchr("",0); } +#define xcat(a,b) CAT(a,b) +#define uniq(p) xcat(p,__COUNTER__) +#define xcountertest(f) int f; f = 11; printf("%d\n", f); +#define countertest(v) xcountertest(uniq(v)) + #ifdef CMD_WORKING int main(V) @@ -93,5 +100,8 @@ S\ ); gnu_ext(printf, "ok %s", "...") gnu_ext(printf, "\n"); + countertest(ww); + countertest(ww); + CAT(ret,urn) 0; } -- cgit v1.2.3