Boost logo

Boost :

Subject: Re: [boost] Re : [preprocessor] ifdef equivalent inside a macro, is it possible?
From: Maxime van Noppen (maxime_at_[hidden])
Date: 2011-08-10 11:29:01


On 08/10/2011 05:22 PM, damien benoist wrote:
> Yes, I've seen that.
>
> I think I've also seen the possibility to test wether it
> expends to 0 or any number from 1 to some maximum.
>
> And some people here also talked about chaos.
> It seems that it also alowsto test wether a macro
> expands to "0 and nothing (i.e. a placemarker)"
> (chaos_pp_placemarker_if)
> It is described as C99 specific (I suppose it uses __VA_ARGS__).
>
> But what I would like is to expand to some value
> by default and another if a given macro is set.

You can do something like:

#ifdef FOO
# define FOO_ISSET 1
#else
# define FOO_ISSET 0
#endif

# define BAR BOOST_PP_IF(FOO_ISSET, FOO, bar)

-- 
Maxime

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk