A
Alexander Ulyanov
Hi all.
Is it possible to pass the whole blocks of code (possibly including
" and ,) as macro parameters?
I want to do something like:
MACRO(FOO, "Foo",
"return "Foobar";",
"foo(); bar();")
(just an example, obviously this won't compile)
being parsed to:
1.
P_FOO, /* Part of enum */
2.
"FOO", /* Part of string literal array */
3.
"Foo", /* Part of string literal array */
4.
case P_FOO: /* Part of switch */
return "Foobar";
break;
5.
case P_FOO: /* Part of switch */
foo(); bar();
break;
Depending on some #define, of course. I don't want to edit five
source files to add or remove something; keeping them consistent
is difficult.
I'm currently doing this with a m4 macro and it works fine, but I'd
like to avoid using an extra tool (which may not be available on
Windows or other non-UNIX systems).
Is it possible to pass the whole blocks of code (possibly including
" and ,) as macro parameters?
I want to do something like:
MACRO(FOO, "Foo",
"return "Foobar";",
"foo(); bar();")
(just an example, obviously this won't compile)
being parsed to:
1.
P_FOO, /* Part of enum */
2.
"FOO", /* Part of string literal array */
3.
"Foo", /* Part of string literal array */
4.
case P_FOO: /* Part of switch */
return "Foobar";
break;
5.
case P_FOO: /* Part of switch */
foo(); bar();
break;
Depending on some #define, of course. I don't want to edit five
source files to add or remove something; keeping them consistent
is difficult.
I'm currently doing this with a m4 macro and it works fine, but I'd
like to avoid using an extra tool (which may not be available on
Windows or other non-UNIX systems).