]>
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
6 // Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
10 #ifndef _WX_MSW_SEH_H_
11 #define _WX_MSW_SEH_H_
13 #if wxUSE_ON_FATAL_EXCEPTION
15 // the exception handler which should be called from the exception filter
17 // it calsl wxApp::OnFatalException() if possible
18 extern unsigned long wxGlobalSEHandler(EXCEPTION_POINTERS
*pExcPtrs
);
20 // helper macro for wxSEH_HANDLE
21 #if defined(__BORLANDC__) || (defined(__VISUALC__) && (__VISUALC__ <= 1200))
22 // some compilers don't understand that this code is unreachable and warn
23 // about no value being returned from the function without it, so calm them
25 #define wxSEH_DUMMY_RETURN(rc) return rc;
27 #define wxSEH_DUMMY_RETURN(rc)
30 // macros which allow to avoid many #if wxUSE_ON_FATAL_EXCEPTION in the code
32 #define wxSEH_TRY __try
33 #define wxSEH_IGNORE __except ( EXCEPTION_EXECUTE_HANDLER ) { }
34 #define wxSEH_HANDLE(rc) \
35 __except ( wxGlobalSEHandler(GetExceptionInformation()) ) \
37 /* use the same exit code as abort() */ \
40 wxSEH_DUMMY_RETURN(rc) \
43 #else // wxUSE_ON_FATAL_EXCEPTION
46 #define wxSEH_HANDLE(rc)
47 #endif // wxUSE_ON_FATAL_EXCEPTION
49 #if wxUSE_ON_FATAL_EXCEPTION && defined(__VISUALC__) && !defined(__WXWINCE__)
52 // C++ exception to structured exceptions translator: we need it in order
53 // to prevent VC++ from "helpfully" translating structured exceptions (such
54 // as division by 0 or access violation) to C++ pseudo-exceptions
55 extern void wxSETranslator(unsigned int code
, EXCEPTION_POINTERS
*ep
);
57 // up to VC 11 this warning ("calling _set_se_translator() requires /EHa")
58 // is harmless and it's easier to suppress it than use different makefiles
59 // for VC5 and 6 (which don't support /EHa at all) and VC7+ (which does
60 // accept it but it seems to change nothing for it anyhow)
61 #if __VISUALC__ < 1800
62 #pragma warning(disable: 4535)
65 // note that the SE translator must be called wxSETranslator!
66 #define DisableAutomaticSETranslator() _set_se_translator(wxSETranslator)
68 // the other compilers do nothing as stupid by default so nothing to do for
70 #define DisableAutomaticSETranslator()
71 #endif // __VISUALC__/!__VISUALC__
73 #endif // _WX_MSW_SEH_H_