Author Topic: Preprocessor: re-use macroname with variadic macro  (Read 1548 times)


  • Guest
Preprocessor: re-use macroname with variadic macro
« on: February 03, 2012, 08:52:27 am »
Hallo, thanks a lot for this tool - I use it in combination with GCC, Watcom, TCC and other compilers/tools to optimize my source for a private project. Currently I only use the command line with pocc.exe and polink.exe for an easier compiler-switching. Windows XP, 32 bit.

I often re-use one letter for different Macros. There is one very special item I found.
"#undef" seems (partly) not to clean a macro name correctly.

Input source: 2 times the same macro definition (no sense, to show the problem)

int main(int argc, char **argvS) {
#define X(a,...) printf(a,__VA_ARGS__)
#undef X
#define X(a,...) printf(a,__VA_ARGS__)
#undef X
return 0;} now create preprocessor output with a command similar:
pocc.exe /E source.c >source_prep.txt

Result for Compiler Version 6.50 (I tried out this beta-version after having found the bug in version 6). The second Macro translation didn't work. Without variadic macros (including "...")  there is no problem.

int main(int argc, char **argvS) {
X("%s","Hello2");  // problem, not translated
return 0;}

« Last Edit: February 29, 2012, 07:36:22 am by mitreder »