I am getting an error that says:
error: looser throw specifier for 'virtual CPLAT::CP_Window::~CP_Window()'
On the destructor, I have never heard of this before and some Google Searches say this might be a GCC 4 problem, which I would not be sure how to work around since I need GCC 4 to build a Universal Binary.
My Environment: OS X 10.6, XCode 3.2.2, GCC 4 to build a universal binary.
What is the issue?
I assume that CPLAT has a base class? I'm also guessing that you did not put a throw specifier on CPLAT's destructor?
You can put throw(X)
(where X is a comma-separated list of exceptions) at the end of a function's signature to indicate what exceptions it's allowed to throw. If you put throw()
as the throw specifier, then it would indicate that no exceptions can be thrown from that function. It's fairly common to do this with destructors since you don't ever want a destructor to throw an exception.
A class that overrides a function which has a throw specifier cannot have a looser throw specifier (list more exceptions) than the function being overridden, since that would indicate that the derived class' function could violate the throw specifier of the base class' function. Not having a throw specifier means that any exception can be thrown from that function, so it's as loose as it can get.
In all likelihood, you need to add throw()
to the end of the function signature of CPLAT's destructor.
Edit: By the way, I should probably add that you probably don't want to use throw specifiers (other than throw()
on destructors) without really knowing that that's what you want. Unlike Java's checked exceptions, they're not caught at compile-time but rather terminate your program at runtime if violated. So, it's best not to use them unless you know what you're doing.
http://www.agapow.net/programming/cpp/looser-throw-specifier
Did you put throw() after the declaration of ~CP_Window() ?
Top link in google search "looser throw specifier" BTW.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With