question regarding macros
Cristian Coarfa
ccristi@cs.rice.edu
Wed Jun 4 21:46:00 GMT 2003
Hi,
I am trying to preprocess the following code with gcc-3.3
#define EXPAND2(pred, args) \
EXPAND3(pred, handler, args)
#define EXPAND3(pred, handler, args) \
((pred) ? \
1 : \
(handler ## args))
result = EXPAND2( predicate, (arg1, arg2, arg3));
What I am trying to achieve is
result = ((predicate) ? 1 : (handler (arg1, arg2, arg3)));
This produces a warning with gcc-3.2.2, but produces the desired result.
The warning is:
pasting "handler" and "(" does not give a valid preprocessing token
gcc 3.3 gives the same message, but produces an error instead.
Are these macros standard conformant, and if not, how do I make them so ?
Thanks,
Cristian
More information about the Gcc
mailing list