"Ronald F. Guilmette" <r...@tristatelogic.com> writes: > I'd like to propose a small enhancement for the GNU preprocessor, i.e. > the addition of a new __MACRO__ pre-defined built-in symbol.
We support the __COUNTER__ macro these days. To get __COUNTER__ to be expaned as you wish, you have to pass it through another macro expansion. So, for example, something like the following should work. #define APP(a, b) a ## b #define VARNAME(a, b) APP(a, b) #define foo1(ARG1,ARG2,V1,V2) \ { \ register int V1 = ARG1; \ register int V2 = ARG2; \ foobar = V1 + V2; \ } #define foo(ARG1,ARG2) \ foo1(ARG1, ARG2, VARNAME(macro_arg1_, __COUNTER__), \ VARNAME(macro_arg2_, __COUNTER__)) #define bar1(ARG1,ARG2,V1,V2) \ { \ register int V1 = ARG1; \ register int V2 = ARG2; \ foo (V1, V2); \ } #define bar(ARG1,ARG2) \ bar1(ARG1, ARG2, VARNAME(macro_arg1_, __COUNTER__), \ VARNAME(macro_arg2_, __COUNTER__)) Ian