Boost logo

Boost :

Subject: Re: [boost] Boost 1.49 BOOST_PP_ITERATION_FLAGS(): causes build failures; would like a boost maintainer comment
From: Paul Mensonides (pmenso57_at_[hidden])
Date: 2012-03-11 12:49:26


On Sun, 11 Mar 2012 16:33:49 +0000, Paul Mensonides wrote:

> #if !defined(MACRO)
> // ...
> #else
> #if MACRO()
> // ...
> #endif
> #endif

In the original scenario:

#if !defined(MACRO)
    // ...
#elif MACRO()
    // ...
#endif

The undefined name MACRO is replaced by 0, so the parser actually sees 0()
and hence the error.

I suppose that I *could* define all of these (it isn't just
BOOST_PP_ITERATION_FLAGS) to have values in the non-iterating case such as:

#define BOOST_PP_ITERATION_FLAGS_0() 0
// etc.

However, that comes at the cost of giving a defined value to something
that should not have a defined value (i.e. should be an error when used
outside an iteration). It also doesn't solve the general problem
introduced by GCC's overzealous parsing which produces behavior that is
positively bizarre:

#if !defined(MACRO)
    #ifndef NDEBUG
        #define MACRO() 123
    #endif
#elif MACRO()
    // ...
#endif

$ g++ -E -P -std=c++0x 1.cpp

$ g++ -E -P -std=c++0x -D NDEBUG 1.cpp
1.cpp:5:12: error: missing binary operator before token "("

Regards,
Paul Mensonides


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