|
Boost : |
Subject: Re: [boost] [wave] preprocessor directives in output
From: Hartmut Kaiser (hartmut.kaiser_at_[hidden])
Date: 2014-01-21 08:47:11
> I'm looking at automating the regeneration of Fusion's preprocess headers
> with the wave tool. Currently, it's impossible because of stuff like this
> (from container\vector\vector.hpp):
>
> #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
> vector(vector&& rhs)
> : vec(std::forward<vector_n>(rhs.vec)) {} #endif
>
> When the wave driver is run, either BOOST_NO_CXX11_RVALUE_REFERENCES is
> defined, in which case the block of code gets left out, or else it isn't,
> in which case the block of code is left in. Both are wrong. What should
> happen is that the #if and #else directives should be present in wave's
> output.
>
> I can keep wave from expanding certain named macros with the -N switch,
> but there doesn't seem to be a way to selectively keep wave from
> evaluating #if/#else directives. Or is there?
The only way I can see this resolved is to do:
// this has to go outside of a #pragma wave option(output: ...) block,
// allowing it to go unchanged into the 'generated' code
//
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
# define VECTOR_MOVE_CTOR() \
vector(vector&& rhs) : vec(std::forward<vector_n>(rhs.vec)) {}
#else
# define VECTOR_MOVE_CTOR()
#endif
Then place this into your vector class:
VECTOR_MOVE_CTOR()
instead of the original code above.
And then pass -NVECTOR_MOVE_CTOR to the Wave tool to inhibit expansion of
this particular macro. This will defer the expansion of the macro to the
actual compiler. I know it's painful, but it's the only viable way.
HTH
Regards Hartmut
---------------
http://boost-spirit.com
http://stellar.cct.lsu.edu
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk