Boost logo

Boost :

From: Hartmut Kaiser (hartmut.kaiser_at_[hidden])
Date: 2005-12-04 11:59:39

Vambola Kotkas wrote:

> Wave Driver C++ preprocessor seems quite useful tool to see what
> happens with most macros. Unfortunatelly it needs some debugging
> before it can be used to preprocess real code. For example it refuses
> (unneccessarily) to process sometimes.
> Silly example 1:
> #if __LINE__ == 11112223334
> #pragma message( "Huh!" )
> #endif
> Result:
> test.cpp(1): error: ill formed integer literal or integer constant
> too
> large: 11112223334.
> None of the available wave flags did seemingly help. Not that i need
> huge integers, however boost sometimes does have way bigger ones so it
> must be legal? MS Visual C++ 7.1 processes constants like
> 18446744073709551615 without any noise.
> See ... 1.33.0 boost/cstdint.hpp line(263):
> # if ULONG_MAX == 18446744073709551615 // 2**64 - 1

It's not legal for 32 bit systems. Either flag the 11112223334 with the LL
suffix (and the --long_long command line option) or you are out of luck with
Wave. At least as long the code is not hidden inside a non-evaluated
#if/#endif block. I've fixed Wave after 1.33.0 to accept large numbers in
non-evaluated #if expressions, just to allow to compile Boost.

> Silly example 2:
> #define SHOW2(x) #x
> #define SHOW(x) SHOW2(Number is:##x)
> #pragma message( SHOW(__LINE__))
> Result:
> test.cpp(3): error: pasting the following two tokens does not give a
> valid preprocessing token: ":" and "__LINE__"

Concatenating two unrelated tokens isn't allowed by the C++ Standard. If you
really need this just provide the --variadics command line option, which
will enable certain C99 features in C++ (variadics, token concatination of
unrelated tokens etc.)

> Maybe its buggy and MS made its preprocessor too lousy there ... just
> for reference Visual C++ 7.1 preprocess result:

Yes, the MSVC preprocessor is lousy.

> Side question: How to force wave to use full paths in #line
> directives?
> Larger projects may contain similarily named files and people
> usually have multiple versions of their own software, nothing
> to talk of libraries and SDK-s.

Wave does use full paths in #line directives as long as the corresponding
files are not in the directory of the main file.

> Silly thing 2 can be
> transformed into Working thing 2:
> #define SHOW2(x) #x
> #define SHOW(x) SHOW2(x)
> #pragma message("Number is:" SHOW(__LINE__)) Wave produces
> same output as VC++ 7.1 then:
> #line 3 "test.cpp"
> #pragma message("Number is:" "3")

What's silly here?

> Finally ... fair test for preprocessor is if it preprocesses
> its own code.
> That makes wave to crash with "unexpected exception caught."
> Various sets of -P and -D options make it to crash in various
> places. I did not manage to find a good set of options so it
> does not crash. How to compile debug version of wave with
> vc7.1?

bjam "-sBUILD=<debug>" ...


> Without debugging it is hard to further track down
> what is going on there. I tried the wave in boost 1.33.0.

Frankly speaking, I haven't done this for a long time. So I tried today and
got several errors/warnings reported by Wave (which I have to investigate
further), but I didn't get any segfault! I'll report on this list with my

Could you please elaborate on which compiler you used to generate Wave,
which command line options did you use?

Regards Hartmut

Boost list run by bdawes at, gregod at, cpdaniel at, john at