From 824dcebe59f52a686b003214c1af0633cf5fe89e Mon Sep 17 00:00:00 2001 From: Michael Matz Date: Sun, 9 Jul 2017 05:30:47 +0200 Subject: tccpp: Implement __COUNTER__ This requires one more change in how macro arguments are expanded: the standard requires that macro args are expanded before substituting into the replacement list. This implies expanding them only once even when they occur multiple times in the list. TCC expanded them repeatedly in that case. Without __COUNTER__ that's harmless. So, simply always expand arguments (when used without # and ##) once and store the resulting tokens. --- libtcc.c | 1 + 1 file changed, 1 insertion(+) (limited to 'libtcc.c') diff --git a/libtcc.c b/libtcc.c index 0e5f55b..ba50ddf 100644 --- a/libtcc.c +++ b/libtcc.c @@ -762,6 +762,7 @@ LIBTCCAPI TCCState *tcc_new(void) define_push(TOK___FILE__, MACRO_OBJ, NULL, NULL); define_push(TOK___DATE__, MACRO_OBJ, NULL, NULL); define_push(TOK___TIME__, MACRO_OBJ, NULL, NULL); + define_push(TOK___COUNTER__, MACRO_OBJ, NULL, NULL); { /* define __TINYC__ 92X */ char buffer[32]; int a,b,c; -- cgit v1.3.1