Boost logo

Boost :

Subject: Re: [boost] [Preprocessor] Adding variadic macros support
From: Paul Mensonides (pmenso57_at_[hidden])
Date: 2010-11-29 10:24:17


On Mon, 29 Nov 2010 09:55:40 -0500, Edward Diener wrote:

>> The first file (w/lambda) takes about 49.4 seconds to preprocess with
>> g++ on my Linux VM. The second file (w/o lambda) takes about 1.9
>> seconds to preprocess.
>
> The 49.4 seconds really is slow. Despite my protestations about
> programmers complaining about compile times, if it took nearly a minute
> to compile a single source file I would find this very unusual. I am not
> sure what you mean by a Linux VM however. Are you running under VMWare,
> or something similar ? Maybe that explains the slow time as opposed to
> running natively. I will try it myself and see the difference in timing,
> but I admit I am a Windows person largely, although I have a number of
> Linux distros into which I occasionally boot, so I will try it under
> Windows with mingw/gcc.

Its a Linux distro running under VirtualBox on my laptop. Running
outside the VM would be somewhat faster. The point being, however, is
not the actual timings, but the ratio between them. The VM has enough
RAM that disk swap is not kicking in.

> I would guess that if you found maintaining the lambda interface to
> Chaos was too much work, particularly as you decide to add any new
> functionality to Chaos, you could drop it. Otherwise just documenting
> that it is much slower during compilation IMO would be adequate.

Maintaining the interface isn't terribly difficult.

>> #define SUM(seq) \
>> CHAOS_PP_EXPR(CHAOS_PP_SEQ_FOLD_LEFT( \
>> SUM_O., seq, 0 \
>> )) \
>> /**/
>> #define SUM_O(x, y) CHAOS_PP_ADD(x, y
>>
>> SUM( (1)(2)(3) )
>>
>> This yields
>>
>> => SUM_O.(3, 3, SUM_O.(3, 2, SUM_O.(3, 1, 0)))
>
> I have never seen this technique before for debugging macros. Is this
> something built-in to Chaos or something the compiler reacts to ?

It is nothing fancy; I simply passed "SUM_O." instead of "SUM_O" to the
fold algorithm.

> Whenever I have gotten error messages from incorrect macros, using Boost
> PP, I just break down the macro from the inside as much as possible,
> into test pieces, and turn on the compiler switch that gives me
> proprocessed output.

That does have to be done sometimes.

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