This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

using same macro arg as both: var and "var"?


Hi all,

I would like to define a macro with a single arg which
shall be used in both ways: The quoted and unquoted way:

#define macro1(a) void func##a(){ printf(a); }

Either way, of course, I get an error:

macro1(x);	  /* error: 'x' in printf not quoted */
macro1("x")	  /* error: func"x" not a func name */;


Instead I use a workaround with two args

#define macro2(a,b) void func##a(){ printf(b); }

However, the usage is not convincing:

macro2(x,"x");
macro2(a_long_name,"a_long_name");
...

 Felix



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]