[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,
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)...
This was a bug in Wave which is fixed now. Thanks for reporting!
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?
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...).
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.
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.
-----Ursprüngliche Nachricht----- Von: Hartmut Kaiser [mailto:hartmut.kaiser@gmail.com] Gesendet: Mittwoch, 4. Juli 2007 21:31 An: boost-users@lists.boost.org Betreff: Re: [Boost-users] [wave] some more question...
[...]
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...).
If I get CVS Head revisions of wave and spirit, this should be fine. Isn't it?
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.
This isn't implemented yet and requires a bit more effort to do so. Give me some time to think about this, ok?
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. ;)
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).
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.
HTH Regards Hartmut
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Best Regards, Ovanes
Ovanes,
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...).
If I get CVS Head revisions of wave and spirit, this should be fine. Isn't it?
This should be fine.
This isn't implemented yet and requires a bit more effort to do so. Give me some time to think about this, ok?
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. ;)
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.
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).
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.
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,
I had a program using wave in boost_33_1 that worked perfect. It used wave library as a preprocessor to a script parser, and it worked with boost_33_1. But when I was trying to compile it with wave in boost 1_34_0, I got error. I think it might be a known problem to you guys and you might know the solution to the problem.
The program code that give error was: lexer_type it = lexer_type(instr.begin(), instr.end(), pos, boost::wave::language_support( boost::wave::support_cpp|boost::wave::support_long_long));
And the error was:
C2039: 'support_long_long' : is not a member of 'boost::wave' 1>c:\users\diamond\src\scriptpreproc.cpp(80) : error C2065: 'support_long_long' : undeclared identifier 1>c:\users\diamond\src\scriptpreproc.cpp(80) : error C2514: 'boost::wave::language_support' : class has no constructors 1> c:\users\tools\boost\boost_1_34_0\boost\wave\language_support. hpp(25) : see declaration of 'boost::wave::language_support' 1>c:\users\diamond\src\scriptpreproc.cpp(80) : error C2661: 'boost::wave::cpplexer::lex_iterator<TokenT>::lex_iterator' : no overloaded function takes 4 arguments
Can you please point me to the right direction or give me a tip to resolve this problem?
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,
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.
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