Boost logo

Boost :

Subject: Re: [boost] Re : Re : Re : [preprocessor] ifdef equivalent inside a macro, is it possible?
From: Edward Diener (eldiener_at_[hidden])
Date: 2011-08-11 15:26:31


On 8/11/2011 10:25 AM, Mathias Gaunard wrote:
> 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 ?
>
> 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.

I would like to see that code. Within a macro you can test a macro for a
value, given a limited subset of possible values, but I do not think you
can test whether a macro is actually defined or not without first
setting another macro to a value based on it, as in:

#if defined(SOME_MACRO)
#define ANOTHER_MACRO 1
#else
#define ANOTHER_MACRO 0
#endif

#define TEST_MACRO
BOOST_PP_IIF(ANOTHER_MACRO,DO_WHEN_SOME_MACRO_DEFINED,DO_WHEN_SOME_MACRO_UNDEFINED)

Eddie


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