]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/seh.h
Add an empty implementation of the OSXGenerateEvent() pure virtual so the generic...
[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
6// RCS-ID: $Id$
7// Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
8// Licence: wxWindows licence
9///////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_MSW_SEH_H_
12#define _WX_MSW_SEH_H_
13
14#if wxUSE_ON_FATAL_EXCEPTION
15
16 // the exception handler which should be called from the exception filter
17 //
18 // it calsl wxApp::OnFatalException() if possible
19 extern unsigned long wxGlobalSEHandler(EXCEPTION_POINTERS *pExcPtrs);
20
21 // helper macro for wxSEH_HANDLE
2e960982 22#if defined(__BORLANDC__) || (defined(__VISUALC__) && (__VISUALC__ <= 1200))
39ea2103
VZ
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
25 // down
26 #define wxSEH_DUMMY_RETURN(rc) return rc;
27#else
28 #define wxSEH_DUMMY_RETURN(rc)
29#endif
30
31 // macros which allow to avoid many #if wxUSE_ON_FATAL_EXCEPTION in the code
32 // which uses them
33 #define wxSEH_TRY __try
34 #define wxSEH_IGNORE __except ( EXCEPTION_EXECUTE_HANDLER ) { }
35 #define wxSEH_HANDLE(rc) \
36 __except ( wxGlobalSEHandler(GetExceptionInformation()) ) \
37 { \
38 /* use the same exit code as abort() */ \
39 ::ExitProcess(3); \
40 \
41 wxSEH_DUMMY_RETURN(rc) \
42 }
43
44#else // wxUSE_ON_FATAL_EXCEPTION
45 #define wxSEH_TRY
46 #define wxSEH_IGNORE
47 #define wxSEH_HANDLE(rc)
48#endif // wxUSE_ON_FATAL_EXCEPTION
49
3c77aabe 50#if wxUSE_ON_FATAL_EXCEPTION && defined(__VISUALC__) && !defined(__WXWINCE__)
39ea2103
VZ
51 #include <eh.h>
52
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);
57
54705127 58 // up to VC 9 this warning ("calling _set_se_translator() requires /EHa")
39ea2103
VZ
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)
54705127 62 #if __VISUALC__ < 1600
39ea2103
VZ
63 #pragma warning(disable: 4535)
64 #endif
65
66 // note that the SE translator must be called wxSETranslator!
67 #define DisableAutomaticSETranslator() _set_se_translator(wxSETranslator)
68#else // !__VISUALC__
69 // the other compilers do nothing as stupid by default so nothing to do for
70 // them
71 #define DisableAutomaticSETranslator()
72#endif // __VISUALC__/!__VISUALC__
73
74#endif // _WX_MSW_SEH_H_