Re: c++ exceptions
Re: c++ exceptions
- Subject: Re: c++ exceptions
- From: David Leimbach <email@hidden>
- Date: Tue, 16 Mar 2010 11:57:51 -0700
On Tue, Mar 16, 2010 at 11:40 AM, Jens Alfke
<email@hidden> wrote:
On Mar 16, 2010, at 8:37 AM, Joel Reymont wrote:
The worst case is where your code calls a system framework that calls back into your code, and that bit of your code throws an exception that’s caught by your outer code. The system code in the middle gets unwound without being able to clean up, which can often cause really nasty problems later on.
So how do you make sure this doesn't happen or code around it?
Ideally C++ would have the same kind of exception-checking that Java does, so you could declare a function as not throwing any exception and have the compiler enforce that for you. But C++ doesn't work that way. So you just have to be careful to wrap all your entry points, including callbacks, in try/catch blocks.
You can turn exceptions off at the compiler with a flag, but that's not a standardized piece of C++ functionality.
Per the gcc man page, -fno-exceptions will do this, or you can grab a bunch of flags under -mkernel.
But you said you wanted exceptions so you're going to have to do something like
try {
// code that you care about
}
catch (...) {
// Catching all uncaught exceptions here.
}
On Mar 16, 2010, at 10:54 AM, Chris Ridd wrote:
WebKit uses exceptions. I *think* I've seen exceptions coming back from WebKit into Obj-C code, but I couldn't swear to it right now.
I am 99% certain WebKit does not use exceptions. I've developed inside WebKit as late as last November, and don't remember seeing any code that threw or caught exceptions. I think they're turned off with compiler flags to reduce code size.
—Jens _______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden