question regarding macros

Falk Hueffner falk.hueffner@student.uni-tuebingen.de
Wed Jun 4 22:21:00 GMT 2003


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



More information about the Gcc mailing list