From: Claudio V. C. <cv...@us...> - 2001-12-31 07:02:25
|
> -----Original Message----- > From: fir...@li... > [mailto:fir...@li...]On Behalf Of Mark > O'Donohue > Sent: Lunes 31 de Diciembre de 2001 1:04 > To: Mike Nordell > > Im trying the gcc 3.0.1 compiler, > I needed to add the following two throw() clauses, > In include/fb_exception.h Here comes the Java-powered aussie to see if he can get his teeth on Mike's work before Mike finishes polishing the thing. :-) > changed: > > virtual ~status_exception() {} > virtual const char* what() const > > to: > > virtual ~status_exception() throw() {} > virtual const char* what() const throw() When you can't compile, you add a couple of reserved words like const, mutable, explicit, virtual, throw(), "&" to mean reference, a template and keep trying until either you or the compiler give up. :-) :-) :-) > When I last did c++, stl was a pup. But the issue here is that the STL was adapted to the features and restrictions of the language. > As I find from reading the manual, > the above restricts the exceptions thrown in the methods to those in the > throws(..) list, which in this case is none. So no exception can be > thrown by these methods. Let's see what is said straight from the horse's mouth, [Stroustrup 2000] in this case: Section 14.6.1: «A virtual function may be overridden only by a function that has an exception-specification at least as restrictive as its own (explicit or implicit) exception-specification.» Section 14.10 defines the root of the standard exceptions: class exception { public: exception() throw(); exception(const exception&) throw(); virtual ~exception() throw(); virtual const char* what() const throw(); Those declarations should be katakana for a pure-Pascal programmer. Had the designers been even more wicked, they could have enacted instead: virtual const char *const what() const throw(); that would have been funnier. :-) Since status_exception and the other two exceptions come from std::exception (why not creating a base class for FB exceptions?), it can't offer a function that's less restrictive than the original and since the original functions say "we don't throw any exception", there's no other alternative for the overriden functions. I think Mike used the redundant "virtual" keyword for documentation purposes, since it should be harmless (the base functions are already virtual). > Is that a problem for you (John/Mike) if I put these in? At least for Mike, no, since the MSVC compiler DOESN'T CARE about the exception-specification part, it will simply ignore that declaration. The Borland compiler cares and obviously, gcc does care. > And, I know this meant to be part of the joys of debugging > templates/namespaces under c++, but how do I fix the following. The > error is: > > ../../src/jrd/gds.cpp:2463: instantiated from here > /usr/include/g++-v3/bits/basic_string.h:169: passing `const > Firebird::allocator<char>' as `this' argument of `bool > Firebird::allocator<T>::operator==(const Firebird::allocator<T>&) > [with T = > char]' discards qualifiers It seems related to the constant literal string used there: > const Firebird::string regPrefix = > FirebirdConfig::getSysString("RootDirectory"); Do you get a warning or an error? C. --------- Claudio Valderrama C. Ingeniero en Informática - Consultor independiente http://www.cvalde.com - http://www.firebirdSQL.org |