boag@cuff.uucp (Scott Boag) (03/28/91)
We are about to implement a generalized error handling scheme that uses catch/throw (i.e. setjump/longjump). I am a bit worried about the behavior of these functions in the MS Windows environment. Has anyone had prior experience with using these? Thanks in advance.
boyd_m@intertel.UUCP (Mark Boyd) (03/28/91)
In article <1991Mar27.182820.17579@cuff.uucp>, boag@cuff.uucp (Scott Boag) writes: > We are about to implement a generalized error handling scheme that uses > catch/throw (i.e. setjump/longjump). I am a bit worried about the > behavior of these functions in the MS Windows environment. Has anyone > had prior experience with using these? Thanks in advance. We used these in our Windows program but to a slightly different tune. We did the CATCH right before the message loop in the WinMain routine. We then used THROW to get back to this location when we needed to terminate the system due to a fatal error. It worked fine and we never had any problems. Mark Boyd Inter-Tel, Inc.
jeff@cdp.UUCP (03/28/91)
I recently used Catch/Throw in an application. If you've used setjmp/longjmp before, you should have no problems. Jeff Dean jeff@cdp.igc.org uunet!pyramid!cdp!jeff
bonneau@hyper.hyper.com (Paul Bonneau) (03/29/91)
In article <1991Mar27.182820.17579@cuff.uucp> boag@cuff.uucp (Scott Boag) writes: >We are about to implement a generalized error handling scheme that uses >catch/throw (i.e. setjump/longjump). I am a bit worried about the >behavior of these functions in the MS Windows environment. Has anyone >had prior experience with using these? Thanks in advance. > There are some gotchas to look out for. The major problem is that Windows does not set any Catch()points itself, and as a result its internal state gets screwed up. For example, if you restrict the mouse with ClipCursor() and bag out, the cursor will still be restricted to the rectangle you set. We use Catch() and Throw() in our code, but it only works acceptably if you are careful to set a Catch()point in each routine on the stack that needs to clean up. Even so, I am still have the uneasy feeling it is possible to leave Windows in a weird state, regardless of how careful you are. For example, suppose you run out of memory in response to a WM_KILLFOCUS message, while the focus is being moved to another one of your app's windows. You Throw() up to the main loop and exit the program. The window to receive the focus never got it, since it was destroyed first. But the internal focus variable in User still references the now defunct window. There is no way to handle a situation like this in the app, other than allowing the WM_SETFOCUS message to be received before exiting, which may nto be easy to do. You cannot simply call SetFocus() to another app's window in response to the WM_KILLFOCUS, since SetFocus() is not re-entrant. Hope this helps, cheers - Paul Bonneau.
markley@network.ucsd.edu (Mike Markley) (03/29/91)
In article <1991Mar27.182820.17579@cuff.uucp> boag@cuff.uucp (Scott Boag) writes: >We are about to implement a generalized error handling scheme that uses >catch/throw (i.e. setjump/longjump). I am a bit worried about the >behavior of these functions in the MS Windows environment. Has anyone >had prior experience with using these? Thanks in advance. We use Catch and Throw with out any problems.
cadsi@ccad.uiowa.edu (CADSI) (03/31/91)
From article <1266500002@cdp>, by jeff@cdp.UUCP: > > I recently used Catch/Throw in an application. If you've used > setjmp/longjmp before, you should have no problems. One thing is interesting about these. They are used via typecast structures (in this case, arrays). Thus, when you send a pointer to the thing, the compiler nags about superfluous & before array. Geeze, I wish MS would think about these things. I like to write warning free code (well as much as possible). In order to remove this message, I remove the &. This will be real nice if Windows SDK ever decides to implement this stuf as a structure. |----------------------------------------------------------------------------| |Tom Hite | The views expressed by me | |Manager, Product development | are mine, not necessarily | |CADSI (Computer Aided Design Software Inc. | the views of CADSI. | |----------------------------------------------------------------------------|
jerry@polygen.uucp (Jerry Shekhel) (04/02/91)
boag@cuff.uucp (Scott Boag) writes: > >We are about to implement a generalized error handling scheme that uses >catch/throw (i.e. setjump/longjump). I am a bit worried about the >behavior of these functions in the MS Windows environment. Has anyone >had prior experience with using these? Thanks in advance. > I use the Catch() and Throw() functions in a Windows game that I'm about to release. They work great, as long as you remember, of course, that you can't Throw() into a deeper stack level than where you're at. In other words, you can always Throw() to WinMain(), but if you're in WinMain(), you can't Throw() to any other function. -- +-------------------+----------------------+---------------------------------+ | JERRY J. SHEKHEL | POLYGEN CORPORATION | When I was young, I had to walk | | Drummers do it... | Waltham, MA USA | to school and back every day -- | | ... In rhythm! | (617) 890-2175 | 20 miles, uphill both ways. | +-------------------+----------------------+---------------------------------+ | ...! [ princeton mit-eddie bu sunne ] !polygen!jerry | | jerry@polygen.com | +----------------------------------------------------------------------------+