This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: question regarding macros
- From: Falk Hueffner <falk dot hueffner at student dot uni-tuebingen dot de>
- To: Cristian Coarfa <ccristi at cs dot rice dot edu>
- Cc: gcc at gcc dot gnu dot org
- Date: 04 Jun 2003 23:46:12 +0200
- Subject: Re: question regarding macros
- References: <3EDE664C.7080308@cs.rice.edu>
Cristian Coarfa <ccristi@cs.rice.edu> writes:
> #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)));
>
> Are these macros standard conformant,
Yes, only their call isn't.
> and if not, how do I make them so ?
Just leave off the ##, since you don't really want to paste tokens
anyway.
--
Falk