[wave] preprocessing error
Hello Hartmut, I have a question to you. I got a header file with an error. The content of a file looks like: #ifndef SOME_GUARD #define SOME_GUARD ... some content #endif SOME_GUARD As you see #endif SOME_GUARD is wrong, standard defines that #endif is followed by a newline. Unfortunately wave threw an exception. Calling what member on the std::exception instance caught resulted in the string: boost::wave::preprocess_exception I spent some time to search where that happened and which line was guilty. Is there any way for you to write the file and line which caused the error? I assume smth bad happens inside the wave lib, since I even can not compare curren and end iterator tokens. With Kind Regards, Ovanes Markarian
Ovanes,
I have a question to you. I got a header file with an error. The content of a file looks like:
#ifndef SOME_GUARD #define SOME_GUARD
... some content
#endif SOME_GUARD
As you see #endif SOME_GUARD is wrong, standard defines that #endif is followed by a newline. Unfortunately wave threw an exception. Calling what member on the std::exception instance caught resulted in the string:
boost::wave::preprocess_exception
I spent some time to search where that happened and which line was guilty. Is there any way for you to write the file and line which caused the error?
I assume smth bad happens inside the wave lib, since I even can not compare curren and end iterator tokens.
Hmmmm, I simply feeded the following snippet to the wave applet #ifndef SOME_GUARD #define SOME_GUARD //... some content #endif SOME_GUARD and got:
wave t.cpp t.cpp:8:1: error: ill formed preprocessor directive: #endif SOME_GUARD t.cpp:9:1: error: detected at least one missing #endif directive
So the bottomline is: it works for me(tm) :-P What version of Wave are you using, what platform/compiler? Do you have a small test reproducing your problem? Regards Hartmut
On Fri, June 22, 2007 18:12, Hartmut Kaiser wrote: [...]
wave t.cpp t.cpp:8:1: error: ill formed preprocessor directive: #endif SOME_GUARD t.cpp:9:1: error: detected at least one missing #endif directive
So the bottomline is: it works for me(tm) :-P
What version of Wave are you using, what platform/compiler? Do you have a small test reproducing your problem?
Regards Hartmut
Harmut, thanks for the answer. I use VC Express 8.0 with boost 1.34, wave comes from the release as well. May be the problem is on my side. My main looks like: int main(int argc, char* argv[]) { try { cmd_processor cmd(argc, argv); cmd.process(); } catch(std::exception const& e) { std::cerr << e.what() << nl << nl; return 2; } catch(...) { std::cerr << "Unknown exception occured..." << std::endl; return 3; } return 0; } After the snippet specified I come into the case with std::execption and e.what() returns boost::wave::preprocessor. Debugging through what()... I came into the class preprocess_exception and found additional methods, which give me more info. Unfortunately, I rely on the standard (std::exception) interface and don't like the idea of writing hundres of 'if's or 'else if's or doing many 'dynamic_cast's to distinguish exceptions. I believe that every exception should give me enough description by calling the what function. May be this is stupid... ;) Would like to hear your statement. Many thanks! Ovanes
Ovanes,
thanks for the answer. I use VC Express 8.0 with boost 1.34, wave comes from the release as well. May be the problem is on my side. My main looks like:
int main(int argc, char* argv[]) { try { cmd_processor cmd(argc, argv); cmd.process(); }
I'ld suggest to add a special catch for the Wave exceptions here: catch(boost::wave::cpp_exception const& e) { // ... } This avoids to use dynamic_cast or other tricks.
catch(std::exception const& e) { std::cerr << e.what() << nl << nl; return 2; } catch(...) { std::cerr << "Unknown exception occured..." << std::endl; return 3; }
return 0; }
After the snippet specified I come into the case with std::execption and e.what() returns boost::wave::preprocessor.
Debugging through what()... I came into the class preprocess_exception and found additional methods, which give me more info. Unfortunately, I rely on the standard (std::exception) interface and don't like the idea of writing hundres of 'if's or 'else if's or doing many 'dynamic_cast's to distinguish exceptions. I believe that every exception should give me enough description by calling the what function. May be this is stupid... ;)
I hear your point! I tried to look around to get a feeling what other libraries do and it seems the information returned by Wave's exception::what() is not the best choice indeed (the standard is very vague here: essentially it says 'what() should return a implementation defined null terminated string'). What I'll do for the next verson of Wave (it's too late for Boost V1.34.1) is to change the exception class to return a string containing more complete descrption of the error (if you want to do something on your local copy for now, just change the preprocess_exception::what() function in cpp_exceptions.hpp to return description()). Regards Hartmut
participants (2)
-
Hartmut Kaiser
-
Ovanes Markarian