]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/seh.h
1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: declarations for SEH (structured exceptions handling) support
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_MSW_SEH_H_
12 #define _WX_MSW_SEH_H_
14 #if wxUSE_ON_FATAL_EXCEPTION
16 // the exception handler which should be called from the exception filter
18 // it calsl wxApp::OnFatalException() if possible
19 extern unsigned long wxGlobalSEHandler(EXCEPTION_POINTERS
*pExcPtrs
);
21 // helper macro for wxSEH_HANDLE
22 #if defined(__BORLANDC__) || (defined(__VISUALC__) && (__VISUALC__ <= 1200))
23 // some compilers don't understand that this code is unreachable and warn
24 // about no value being returned from the function without it, so calm them
26 #define wxSEH_DUMMY_RETURN(rc) return rc;
28 #define wxSEH_DUMMY_RETURN(rc)
31 // macros which allow to avoid many #if wxUSE_ON_FATAL_EXCEPTION in the code
33 #define wxSEH_TRY __try
34 #define wxSEH_IGNORE __except ( EXCEPTION_EXECUTE_HANDLER ) { }
35 #define wxSEH_HANDLE(rc) \
36 __except ( wxGlobalSEHandler(GetExceptionInformation()) ) \
38 /* use the same exit code as abort() */ \
41 wxSEH_DUMMY_RETURN(rc) \
44 #else // wxUSE_ON_FATAL_EXCEPTION
47 #define wxSEH_HANDLE(rc)
48 #endif // wxUSE_ON_FATAL_EXCEPTION
50 #if wxUSE_ON_FATAL_EXCEPTION && defined(__VISUALC__) && !defined(__WXWINCE__)
53 // C++ exception to structured exceptions translator: we need it in order
54 // to prevent VC++ from "helpfully" translating structured exceptions (such
55 // as division by 0 or access violation) to C++ pseudo-exceptions
56 extern void wxSETranslator(unsigned int code
, EXCEPTION_POINTERS
*ep
);
58 // up to VC 7.1 this warning ("calling _set_se_translator() requires /EHa")
59 // is harmless and it's easier to suppress it than use different makefiles
60 // for VC5 and 6 (which don't support /EHa at all) and VC7 (which does
61 // accept it but it seems to change nothing for it anyhow)
62 #if __VISUALC__ <= 1310
63 #pragma warning(disable: 4535)
66 // note that the SE translator must be called wxSETranslator!
67 #define DisableAutomaticSETranslator() _set_se_translator(wxSETranslator)
69 // the other compilers do nothing as stupid by default so nothing to do for
71 #define DisableAutomaticSETranslator()
72 #endif // __VISUALC__/!__VISUALC__
74 #endif // _WX_MSW_SEH_H_