Boost logo

Boost :

From: Hartmut Kaiser (HartmutKaiser_at_[hidden])
Date: 2005-02-14 16:22:36


 
Larry Evans wrote:

> Does anyone have a tool that would clarify what's happening
> with some PP macros in, for example:
>
> boost/spirit/fusion/sequence/tuple.hpp

Wave? ;-)

> For example, could wave be used to sort-of trace through the
> macro expansions to make the code easier to understand.
>
> For instance, I'm guessing that:
>
> BOOST_PP_REPEAT_FROM_TO(
> 2, FUSION_MAX_TUPLE_SIZE, FUSION_TUPLE_CONSTRUCTOR, _)
>
> does for 2 to FUSION_MAX_TUPLE_SIZE what:
>
> explicit tuple(typename detail::call_param<T0>::type _0)
> : base_type(_0) {}
>
> Does for a 1 argument CTOR. I could run it through cpp, but
> if there are several nested macro calls, it probably wouldn't
> help much in understand what's going on.

Wave is able to trace the macro invocations. For this to happen you need to
do the following:

- place a pair of #pragma wave trace(on)/#pragma wave trace(off) around the
macro(s) to expand
(note, that in variadics mode, i.e. when specifying --variadics on the
command line, you may want to use the operator _Pragma syntax: _Pragma("wave
trace(on)")/_Pragma("wave trace(off)"), which is handy in some situations,
because it can be placed nearly anywhere in the code)
- specify the --traceto option on the command line ('--traceto file' for
output to 'file' or '--traceto -' for output to stderr)

You should try to narrow the macro expansion to trace to a minimum, because
there will be generated quite a lot output.

HTH
Regards Hartmut


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