Boost logo

Boost :

Subject: Re: [boost] [phoenix] not playing nice with other libs
From: Hartmut Kaiser (hartmut.kaiser_at_[hidden])
Date: 2011-05-07 11:22:27


> > On 5/5/2011 9:36 PM, Hartmut Kaiser wrote:
> > >> Hartmut, you have done some work on a Wave-based tool to help with
> > >> the pre-preprocessing grunt-work, is that right?
> > >
> > > I trust Thomas has answered that already. Just ask if you need more
> > information.
> >
> > Thanks, Hartmut. It works beautifully.
> >
> > One question: what if I don't want the generated files to be
> > *completely* preprocessed? As a trivial example, what if I wanted to
> > leave in simple compiler work-arounds like BOOST_STATIC_CONSTANT and
> > BOOST_DEDUCED_TYPENAME?
>
> Short answer: generally no.
>
> Long answer: if we know what we're doing, and we're sure that those macros
> do not influence any #ifdef's later on, we could suppress the expansion of
> a predefined list of macros. This is easily possible with the Wave
> library, but it is not exposed by the Wave driver program. Let me see what
> I can do to add a corresponding command line option allowing you to tell
> the Wave driver not to expand a certain macro.

Ok, that was easier than I thought it would be. I added a new command line
option --noexpand/-N to Wave allowing to specify a macro name which will not
be expanded in any case. Its invocation will be copied verbatim to the
generated output, just like if it was not defined in the first place.
Function like macros will be copied verbatim with all of their arguments. No
macro expansion will be done for any of the arguments in that case, even if
the argument list contains macros which would be expanded normally.

Use more than one -N for more macro names. Be careful, though: this not only
suppresses the expansion of the macro, it removes the macro from any
consideration for Wave itself. Two problems can be caused by this:

a) If you suppress macros which are part of an #if expression you'll likely
to see preprocessing errors.
b) If the suppressed macro influences the evaluation of #if expressions down
the road, you might get surprises as well.

Overall it should be safe to suppress macros which are used outside of other
preprocessor constructs, like

    BOOST_STATIC_ASSERT(...)

et.al.

Regards Hartmut
---------------
http://boost-spirit.com


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