EH in C (was: Re: (lack of) Thread-safe exceptions on AIX (gcc-2.95.1)

Jamie Lokier
Tue Feb 1 16:24:00 GMT 2000

Zack Weinberg wrote:
> The usual reason people want exceptions in C is to make pthread
> cancellation play nice with C++.  The pthread library has 'cleanups'
> that happen when a thread is cancelled, that are basically
> try/finally, but they don't interoperate with the C++ exception
> mechanism.  What you'd like is for pthread_cleanup_push/pop to be
> implemented in terms of try/catch, and pthread_cancel to throw an
> exception in the cancelled thread.
> That requires only try { } catch (...) { }, plus some way to throw
> an object (not just rethrow), in C.

Actually all it requires is that the pthread_cleanup_push/pop functions
are compiled with the C++ compiler.  That would seem much easier than
extending the C language.  If the library is written to depend on some
GCC extension that was only written for that library anyway...  why not
bite the bullet and compile that one file with G++?

have a nice day,
-- Jamie

More information about the Gcc mailing list