Boost logo

Boost :

Subject: Re: [boost] Re : Re : Re : [preprocessor] ifdef equivalent inside a macro, is it possible?
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2011-08-11 10:25:41


On 11/08/2011 15:05, damien benoist wrote:
>> Is it possible for you to make the macro defined to some special value
>
>> rather than being undefined ?
>
> Yes, but I have many cases like this.
> This time it will look like this
> (the ifdef DEFINE_FOO is not needed):
>
> // my default values
> #define FOO1 foo1
> #define FOO2 foo2
> ...
> #define FOO42 foo42
>
> // optional overriding values
> # define FOO1_OVERRIDE (BOOST_PP_NIL)
> ...
> # define FOO23_OVERRIDE (BOOST_PP_NIL)
>
> // The only macro I would like to have to write
> # define FOO24_OVERRIDE (myFoo24, BOOST_PP_NIL)
>
> # define FOO25_OVERRIDE (BOOST_PP_NIL)
> ...
> # define FOO42_OVERRIDE (BOOST_PP_NIL)
>
>
> And it turns out to be simpler to write:
>
> #define FOO1_OVERRIDE FOO1
> ...
> #define FOO23_OVERRIDE FOO23
> #define FOO24_OVERRIDE myFoo24
> #define FOO25_OVERRIDE FOO25
> ...
> #define FOO42_OVERRIDE FOO42
>
> Thanks for your help.

If you can list the names of all possible macros in some place, then I
think you can make some macro that tests if it is defined or not,
assuming the definition is unary.


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