public inbox for pthreads-win32@sourceware.org
 help / color / mirror / Atom feed
* RE: #define catch?
@ 2000-08-02  8:42 Bossom, John
  2000-08-02  9:50 ` Scott McCaskill
  0 siblings, 1 reply; 6+ messages in thread
From: Bossom, John @ 2000-08-02  8:42 UTC (permalink / raw)
  To: 'Ross Johnson', Scott McCaskill; +Cc: pthreads-win32

"catch" is actually a keyword in C++...

-----Original Message-----
From: Ross Johnson [ mailto:rpj@ise.canberra.edu.au ]
Sent: Wednesday, August 02, 2000 2:27 AM
To: Scott McCaskill
Cc: pthreads-win32@sourceware.cygnus.com
Subject: Re: #define catch?


Scott McCaskill wrote:
> 
> I noticed that pthread.h has a macro that defines 'catch'.  (macro
> reproduced here for convenience)
> 
> /*
>  * Redefine the C++ catch keyword to ensure that applications
>  * propagate our internal exceptions up to the library's internal
handlers.
>  */
> #define catch(E) \
>          catch(Pthread_exception_cancel) \
>          { \
>             throw; \
>          } \
>          catch(Pthread_exception_exit) \
>          { \
>             throw; \
>          } \
>          catch(E)
> 
> This breaks the following legal C++ code (because there will be multiple
> catch blocks for Pthread_exception_cancel and Pthread_exception_exit):
> 
> try {
>     // ...
> }
> 
> catch ( some_exception ) { }
> 
> catch ( some_other_exception ) { }

Hmmm. When I tested this a long time back the macro seemed to be
harmless. The duplication of catch(Pthread_exception_*)
blocks appeared to not affect other exception catch blocks. Maybe
my testing wasn't good enough. I've been assuming that only
the first matching block is executed and duplicates are redundant
but ok.

Without this any catch(...) inside a thread will prevent
cancelation or pthread_exit() from working for that thread.

I'm currently looking into this since I'm not happy with the
current scheme myself. If anyone has any ideas on how to
handle this then please let me know, I'm short on C++ experience.

Ross

> 
> Is this breakage really necessary?  I understand the reason for this
macro,
> but perhaps it should at least be optional?  For now, I checked out the
tree
> and commented it out to work around it (admittedly not a great solution,
but
> I'm not going to rewrite all my code to only use one catch per try).
> 

-- 
+----------------------+---+
| Ross Johnson         |   | E-Mail: rpj@ise.canberra.edu.au
| Info Sciences and Eng|___|
| University of Canberra   | FAX:    +61 6 2015227
| PO Box 1                 |
| Belconnen  ACT    2616   | WWW:    http://willow.canberra.edu.au/~rpj/
| AUSTRALIA                |
+--------------------------+

^ permalink raw reply	[flat|nested] 6+ messages in thread
* #define catch?
@ 2000-08-01 10:27 Scott McCaskill
  2000-08-01 23:27 ` Ross Johnson
  0 siblings, 1 reply; 6+ messages in thread
From: Scott McCaskill @ 2000-08-01 10:27 UTC (permalink / raw)
  To: pthreads-win32

I noticed that pthread.h has a macro that defines 'catch'.  (macro
reproduced here for convenience)

/*
 * Redefine the C++ catch keyword to ensure that applications
 * propagate our internal exceptions up to the library's internal handlers.
 */
#define catch(E) \
         catch(Pthread_exception_cancel) \
         { \
            throw; \
         } \
         catch(Pthread_exception_exit) \
         { \
            throw; \
         } \
         catch(E)

This breaks the following legal C++ code (because there will be multiple
catch blocks for Pthread_exception_cancel and Pthread_exception_exit):

try {
    // ...
}

catch ( some_exception ) { }

catch ( some_other_exception ) { }


Is this breakage really necessary?  I understand the reason for this macro,
but perhaps it should at least be optional?  For now, I checked out the tree
and commented it out to work around it (admittedly not a great solution, but
I'm not going to rewrite all my code to only use one catch per try).

Excellent library, BTW.. I'm quite happy to not have to rewrite a bunch of
thread synchronization code for multiple platforms.

--Scott McCaskill


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2000-08-03 20:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-08-02  8:42 #define catch? Bossom, John
2000-08-02  9:50 ` Scott McCaskill
2000-08-03  9:11   ` Followup -- " Scott McCaskill
2000-08-03 20:14     ` Ross Johnson
  -- strict thread matches above, loose matches on Subject: below --
2000-08-01 10:27 Scott McCaskill
2000-08-01 23:27 ` Ross Johnson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).