This is the mail archive of the pthreads-win32@sources.redhat.com mailing list for the pthreas-win32 project.


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

Re: Followup -- Re: #define catch?


Scott McCaskill wrote:
> 
> Well, after doing some more research, it appears that it *is* legal in C++
> to have multiple catch blocks for the same exception, so apparently this is
> yet another VC++ bug.

In any case, the library aims to work in it's target environments and so
I'm still seeking a way to handle this that is portable. Unfortunately,
thus far I haven't been able to come up with a neat, clean and
transparent
method.

The best I've come up with for VC++ (leaving the current macro
defined for other compilers) is the following:

#ifdef NEED_ALTCATCHALL
#warning Replace any 'catch(...)' with 'AltCatchAll' if you want \
	 Pthread-Win32 cancelation and pthread_exit to work.
#define AltCatchAll \
	catch(Pthread_exception) { throw; } \
	catch(...)	
#else
#define catch(e) \
	catch(Pthread_exception) { throw; } \
	catch(e)	
#endif

[I've now grouped internal library exceptions under a single base
class.]

The application code would need this also for portability:

#include <pthread.h>
#if defined(NEED_ALTCATCHALL) && ! defined(AltCatchAll)
#define AltCatchAll catch(...)
#endif

So unless anyone can offer an alternative I will use this.

Ross

> 
> ----- Original Message -----
> From: "Scott McCaskill" <scott@3dfx.com>
> To: <pthreads-win32@sourceware.cygnus.com>
> Sent: Wednesday, August 02, 2000 11:49 AM
> Subject: Re: #define catch?
> 
> >
> > ----- Original Message -----
> > From: "Bossom, John" <John.Bossom@Cognos.COM>
> > To: "'Ross Johnson'" <rpj@ise.canberra.edu.au>; "Scott McCaskill"
> > <scott@3dfx.com>
> > Cc: <pthreads-win32@sourceware.cygnus.com>
> > Sent: Wednesday, August 02, 2000 10:42 AM
> > Subject: RE: #define catch?
> >
> >
> > > "catch" is actually a keyword in C++...
> > >
> >
> > This is true.. but I don't see what you're getting at.  The fundamental
> > problem I encountered is that this (legal) code:
> >
> > catch ( app_exception ) { }
> > catch ( some_other_app_exception ) { }
> >
> > ..will be expanded to the following when using the macro in pthread.h:
> >
> > catch ( Pthread_exception_cancel ) { throw; }
> > catch ( Pthread_exception_exit ) { throw; }
> > catch ( app_exception ) { }
> > catch ( Pthread_exception_cancel ) { throw; }
> > catch ( Pthread_exception_exit ) { throw; }
> > catch ( some_other_app_exception ) { }
> >
> > ..and VC++ will not compile that because of the existence of multiple
> > handlers for Pthread_exception_cancel and Pthread_exception_exit.
> >

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