Boost logo

Boost :

Subject: Re: [boost] [preprocessor metaprogramming] tools
From: Edward Diener (eldiener_at_[hidden])
Date: 2012-07-05 20:50:03


On 7/5/2012 3:02 AM, Nathan Ridge wrote:
>
> Hello,
>
> I've noticed preprocessor metaprogramming has become more
> popular of late, both as a means to provide a cleaner alternative
> interface to a library (e.g. the DEFINE and ADAPT macros in
> Boost.Fusion or the proposed macro wrappers for Boost.TypeErasure)
> and as a means to emulate new language features (e.g.
> Boost.LocalFunction, Boost.Generic, and Boost.Contract).
>
> Sadly, IDE support for writing macro metaprograms is fairly poor
> in comparison to IDE support for writing regular C++ code.
>
> I wanted to share with you something I've found very useful for
> tracing/debugging macro metaprograms: the Eclipse CDT IDE has a
> "macro stepper" that allows you to step through the expansion of
> a macro step-by-step from the initial invocation to the final
> expansion. (This feature can be accessed by using the "Explore
> Macro Expansion" context menu item on a macro invocation.)
>
> I would be curious to hear what tools you have found useful for
> writing or debugging macro metaprograms.

The problem with debugging macro expansion is that the preprocessor one
is using may be incorrectly expanding a macro and using other tools to
look at the macro expansion will not show you the macro expansion which
the incorrectly expanding preprocessor is doing.

This is particularly the case with VC++. I have already queried on the
Microsoft online forums if VC++ has a means of showing macro expansion
step-by-step and the answer appears to be that it does not. This is not
surprising since such a tool would further highlight VC++'s bugs in
macro expansion, which they have pointedly declined to fix for many,
many years.

Boost already has a solution for viewing macro expansion in a 100%
correct C++ preprocessor: Use the Boost wave with the tracing facility.
This is very easy to do to see how a macro should be expanded. The
Eclipse CDT IDE's "macro stepper" is a welcome edition to how a macro is
expanded as long as the Eclipse C++ implementation's preprocessor is a
100% compliant preprocessor.


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