
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.

-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Vambola Kotkas
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?
It's not. Or, more precisely, all values in expressions in #if or #elif directives are promoted to the largest built-in type--namely, long or unsigned long in current C++. Beyond that, if I recall correctly, underflow and overflow produced by arithmetic results in undefined behavior.
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:
It is undefined behavior to paste together two tokens where the result is not a single token. In this case, and in most cases like this, the concatenation is pointless: #define SHOW(x) SHOW2(Number is:x) Just for the record, BTW, VC++ has a horrible preprocessor. Regards, Paul Mensonides
participants (2)
-
Paul Mensonides
-
Vambola Kotkas