Re: C++ exception results in SIGABRT
Re: C++ exception results in SIGABRT
- Subject: Re: C++ exception results in SIGABRT
- From: Alastair Houghton <email@hidden>
- Date: Tue, 19 Feb 2008 16:55:41 +0000
On 19 Feb 2008, at 16:45, Stefan Werner wrote:
On Feb 18, 2008, at 8:11 PM, Howard Hinnant wrote:
Yes. To propagate a C++ exception through a C stack frame, that C
stack frame must be compiled with -fexceptions (which is defaulted
off for .c files). From the gcc docs:
However, you may need to enable this option when compiling C code
that needs to interoperate properly with exception handlers
written in C++.
Thanks, that was it.
I'm still puzzled about GCC_ENABLE_CPP_EXCEPTIONS though. The built-
in documentation of it in Xcode is a verbatim copy of what the man
page says about -fexceptions. However, GCC_ENABLE_CPP_EXCEPTIONS =
YES odes not add -fexceptions. Is that desired behavior?
It seems desirable to me (to *not* enable it, that is). C code can't
possibly handle a C++ exception, so throwing through a C frame, unless
it's one you have total control over, is a risky thing to do. Even
then, you have to be pretty careful not to e.g. leak resources or
leave the code in an invalid state. Better, therefore, to generate
SIGABRT unless the programmer has specifically said it's OK by
enabling -fexceptions, surely?
Kind regards,
Alastair.
--
http://alastairs-place.net
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden