[Developers] macro as macro argument
David Rideout
d.rideout at imperial.ac.uk
Mon Mar 5 10:06:49 CST 2007
I have a C macro which employs internal variables, e.g.
#define foo(arg1) { \
int internal_var; \
... code(arg1) ... }
Often the macro is invoked multiple times in a single source file, which leads
to a compiler warning about identical variables in scope or something like
this. I tried a hack:
#define foo(arg1, XX) { \
int internal_var##XX; \
... code(arg1) ... }
which I wanted to call with
foo(bar, __LINE__)
to give each internal variable a unique name, but this instead makes each
internal variable into 'internal_var__LINE__'.
Can someone more familiar with the workings of the C preprocessor suggest a
way to avoid this compiler warning?
(I am trying to build an API in Cactus which uses macros, so in this sense the
question is on-topic...)
Many thanks,
David
More information about the Developers
mailing list