]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/seh.h
wxMessageBox off the main thread lost result code.
[wxWidgets.git] / include / wx / msw / seh.h
CommitLineData
39ea2103
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/msw/seh.h
3// Purpose: declarations for SEH (structured exceptions handling) support
4// Author: Vadim Zeitlin
5// Created: 2006-04-26
39ea2103
VZ
6// Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
7// Licence: wxWindows licence
8///////////////////////////////////////////////////////////////////////////////
9
10#ifndef _WX_MSW_SEH_H_
11#define _WX_MSW_SEH_H_
12
13#if wxUSE_ON_FATAL_EXCEPTION
14
15 // the exception handler which should be called from the exception filter
16 //
17 // it calsl wxApp::OnFatalException() if possible
18 extern unsigned long wxGlobalSEHandler(EXCEPTION_POINTERS *pExcPtrs);
19
20 // helper macro for wxSEH_HANDLE
2e960982 21#if defined(__BORLANDC__) || (defined(__VISUALC__) && (__VISUALC__ <= 1200))
39ea2103
VZ
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
24 // down
25 #define wxSEH_DUMMY_RETURN(rc) return rc;
26#else
27 #define wxSEH_DUMMY_RETURN(rc)
28#endif
29
30 // macros which allow to avoid many #if wxUSE_ON_FATAL_EXCEPTION in the code
31 // which uses them
32 #define wxSEH_TRY __try
33 #define wxSEH_IGNORE __except ( EXCEPTION_EXECUTE_HANDLER ) { }
34 #define wxSEH_HANDLE(rc) \
35 __except ( wxGlobalSEHandler(GetExceptionInformation()) ) \
36 { \
37 /* use the same exit code as abort() */ \
38 ::ExitProcess(3); \
39 \
40 wxSEH_DUMMY_RETURN(rc) \
41 }
42
43#else // wxUSE_ON_FATAL_EXCEPTION
44 #define wxSEH_TRY
45 #define wxSEH_IGNORE
46 #define wxSEH_HANDLE(rc)
47#endif // wxUSE_ON_FATAL_EXCEPTION
48
3c77aabe 49#if wxUSE_ON_FATAL_EXCEPTION && defined(__VISUALC__) && !defined(__WXWINCE__)
39ea2103
VZ
50 #include <eh.h>
51
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);
56
5d79e64a 57 // up to VC 11 this warning ("calling _set_se_translator() requires /EHa")
39ea2103 58 // is harmless and it's easier to suppress it than use different makefiles
5d79e64a 59 // for VC5 and 6 (which don't support /EHa at all) and VC7+ (which does
39ea2103 60 // accept it but it seems to change nothing for it anyhow)
5d79e64a 61 #if __VISUALC__ < 1800
39ea2103
VZ
62 #pragma warning(disable: 4535)
63 #endif
64
65 // note that the SE translator must be called wxSETranslator!
66 #define DisableAutomaticSETranslator() _set_se_translator(wxSETranslator)
67#else // !__VISUALC__
68 // the other compilers do nothing as stupid by default so nothing to do for
69 // them
70 #define DisableAutomaticSETranslator()
71#endif // __VISUALC__/!__VISUALC__
72
73#endif // _WX_MSW_SEH_H_