This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Exceptions and C-callbacks?
- To: Rob Kramer <wrobbie at my-Deja dot com>
- Subject: Re: Exceptions and C-callbacks?
- From: <llewelly at 198 dot dsl dot xmission dot com>
- Date: Wed, 9 Feb 2000 00:25:39 -0700 (MST)
- cc: gcc at gcc dot gnu dot org
On Tue, 8 Feb 2000, Rob Kramer wrote:
> Hi all,
>
> A quick question, before I investigate further. My application uses a
> function from a C-library (an event handler) that does a callback to a
> static function in my application class which in turn calls some C++
> code (via a stored 'this' pointer).
>
> Application -> C-event handler -> C-callback -> C++ callback handler.
>
> My problem: the C++ callback handler can throw exceptions, but they
> are never caught in the application and result in an 'Abort!'.
>
> Is this a normal feature of GCC's exception handling mechanism, i.e.
> does the C-callback stuff intercept exceptions in some way?
>
> I'm using DJGPP here by the way, this may be a DOS related issue..
> If my problem is not due to GCC's exception handler, I'll make a
> isolated testcase.
>
> Thanks!
>
> Rob Kramer
> robk@cyberway.com.sg
>
Rebuild the library containing the C-event handler and the C-callback with
-fexceptions ; that tells gcc to include proper stack unwinding info.
See 'info gcc gCode Gen Options' .
I have made this work with glib and gtk+.
If you cannot expect your customer to have the library built with
-fexceptions (I doubt there is a single linux distribution that builds
c libraries with -fexceptions ), then I do not know what to tell you ...
use exceptions only for debugging, and stub out the exception throwing
code in the releases.