[wave] some more question...

Hello Hartmut! I have a file delived from some processor manufacturer which I can not change. In the file I have following defines, which wave can't parse: #define UINT_MAX 4294967295U #define ULONG_MAX 1099511627775U First error which happens during parsing of UINT_MAX is: description: error: ill formed integer literal or integer constant too large: 4294967295U I do not understand why I get the first error, since the value 4294967295U is 0xFFFFFFFF which is 32 bits long and should be fine (since it is also marked as unsigned for the preprocessor)... Clearly the ULONG_MAX has a wrong numeric format (should be 1099511627775UL or 1099511627775ul), but unfortunately this file comes from some vendor and is deeply incorporated into the build process, so that it can not easily be changed. What do you think, could be the possible solution in this case? My other question would be: Is there any change to allow the hooking interface to specify, which preprocessor directives should be expanded, an which not. Let me summarize: I need some few macros to be expanded, which are defined in some 2-3 headers and I do not want wave to preprocess everything (huge source dir). Ideally, it would be great to have some functionality, which can notify the preprocessor whether to skip the preprocessing directive or not, e.g. function void found_include_directive(std::string const &filename, bool include_next); (as well as other functions like expanding_function_like_macro) from the default_preprocessing_hooks interface could additionaly return bool value, which would notify the preprocessor whether to include and expand the file/macro or not. May be in this second case I could solve the first problem as well, since I don't really need these defines, they are parsed as part of dependency, which is not required in my case. With Kind Regards, Ovanes Markarian

Hi Ovanes,
This was a bug in Wave which is fixed now. Thanks for reporting!
Actually it should be 1099511627775ULL (at least on most 32 bit platforms), and even then the preprocessor is not required to recognize it, since the standard requires it to use long/unsigned long as the biggest internal representation of integer literals. To solve this I added the BOOST_WAVE_SUPPORT_LONGLONG_INTEGER_LITERALS compile time configuration constant to Wave, which enables the usage of boost::long_long_type/boost::ulong_long_type for the internal representation of integer literals (only available on platforms supporting these types, i.e. BOOST_HAS_LONG_LONG should be defined). If this is defined during compilaton of the library (not only your app!) then Wave uses the long long types for all integer literals, even if the suffix provided was only 'l' or 'ul' etc. Note, that this option may slow down preprocessing a bit because long long's may require some overhead if compared to long's. Since the option breaks standards conformance it will be disabled by default. But it's useful under certain circumstances (such as yours or when you have to emulate other platforms). The changes are committed to Boost::CVS head. Please note that in order to implement this correctly I had to fix a bug in Spirit as well, which is currently committed to the CVS::HEAD only (we'll try to get this into 1.34.1, but can't promise...).
This isn't implemented yet and requires a bit more effort to do so. Give me some time to think about this, ok? But there is another feature, which might be interesting for you in this context. The Wave driver tool has some #pragma's allowing to redirect or suppress the genereated output, which actually gives you some kind of partial preprocessing feature: #pragma wave option(output: "preprocessed/directory.hpp") Where the argument to the output option may be a "file name", null (no output), default (output as specified on the command line), or push/pop (with the obvious semantics). HTH Regards Hartmut

Hartmut, You are the best! I will download the cvs head revisions.
[...]
If I get CVS Head revisions of wave and spirit, this should be fine. Isn't it?
I can live with the really quick bug fixes you submitted. But I think this can be a nice to have feature, to control the preprocessing process. ;)
If I correctly understand you, I can predefine pragma directives and pass them to context, to suppress some output?? If so, it can be a workaround, but with some harder work to do as the iversion ;) My intention would be to define only 3 headers which might be required for my preprocessing task, as to enumerate all other 30 which should be excluded... And in my case there are different headers (to be excluded) in different app modules, but these 3 headers stay the same.
Best Regards, Ovanes

Ovanes,
This should be fine.
You have it now (see my other mail). Even if I still think its of limited use only (if you skip the expansion of a macro inside a #if expression, the whole expression may get invalid, and there is no way to circumvent that). But please go ahead and try it out.
I was not consise enough: the #pragma's are all implemented in the wave driver by overloading the interpret_pragma() pp hook. So this isn't really an option for you. But you may want to have a look there anyways.... Regards Hartmut

Hi, Hartmut, I did as what you told me, and it fixed the problem. Thank you so much! regards, Fanzhe Cui -----Original Message----- From: Hartmut Kaiser [mailto:hartmut.kaiser@gmail.com] Sent: Wednesday, July 04, 2007 7:21 AM To: 'Fanzhe Cui'; 'Spirit General Mailing List' Subject: RE: Problem with wave in boost 1_34_0 Fanz,
Doh! I was not aware of this interface breaking change in Wave (for this reason its not documented anywhere). As I now remember I unified the naming of the options and flags, so that the option you're using is now named: 'support_option_long_long'. If you change your code accordingly, it should compile again. For your reference: please have a look at the file boost/wave/language_support.hpp, where all related options are defined. Sorry for the trouble, I should have documented this. Regards Hartmut

Ovanes,
The following preprocessing hooks now return a boolean value, which when returning 'true' cause the Wave library to skip the execution of the related preprocessing action: . found_directive: allows to skip the whole directive it is called for . expanding_object_like_macro: allows to skip expansion of the given object like macro, the macro symbol is copied to the output . expanding_function_like_macro: allows to skip the expansion of the given function like macro, the whole macro invocation (including all macro invocation parameters) are copied to the output without any further processing. Please note, that additionally I changed the interpretation of the return value of the found_include_directive() preprocessing hook: a return value of 'false' now processes the file to include normally and a return value of 'true' now skips the processing of the include file. The latter change was necessary to make the return values of the preprocessing hook consistent. Now return 'false' generally means: normal execution and return 'true' generally means: skip execution of the corresponding preprocessor action. HTH Regards Hartmut
participants (3)
-
Fanzhe Cui
-
Hartmut Kaiser
-
Ovanes Markarian