This is the mail archive of the gcc@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]

Re: question regarding macros


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


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