|
Boost : |
From: Vambola Kotkas (vambola.kotkas_at_[hidden])
Date: 2005-12-03 23:22:08
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
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__"
Maybe its buggy and MS made its preprocessor too lousy there ... just for
reference Visual C++ 7.1 preprocess result:
#line 1 "c:\\develop\\vc7test\\test.cpp"
#pragma message( "Number is:3")
Thing to note is that removing the colon from line 2 produces wave output
with contents:
#line 3 "test.cpp"
#pragma message("Number is__LINE__")
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. 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")
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? Without debugging it is hard to further track
down what is going on there. I tried the wave in boost 1.33.0.
Thanks.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk