This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Exceptions and C-callbacks?




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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]