From 06b76f7e8ba4f5882ade265e30d5b4f57eb61e23 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 12 Feb 2010 22:47:25 +0000 Subject: [PATCH] Fix compilation of wx/scopeguard.h with g++ -fno-exceptions. Don't use try/catch in public headers if exceptions support is disabled with a compiler switch. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63474 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/except.h | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/include/wx/except.h b/include/wx/except.h index 0fb5ae4aff..e63d4f9781 100644 --- a/include/wx/except.h +++ b/include/wx/except.h @@ -18,13 +18,22 @@ // macros working whether wxUSE_EXCEPTIONS is 0 or 1 // ---------------------------------------------------------------------------- -#if wxUSE_EXCEPTIONS - #define wxTRY try - #define wxCATCH_ALL(code) catch ( ... ) { code } -#else // !wxUSE_EXCEPTIONS +// even if the library itself was compiled with exceptions support, the user +// code using it might be compiling with a compiler switch disabling them in +// which cases we shouldn't use try/catch in the headers -- this results in +// compilation errors in e.g. wx/scopeguard.h with at least g++ 4 +#if !wxUSE_EXCEPTIONS || \ + (defined(__GNUG__) && !defined(__EXCEPTIONS)) + #define wxNO_EXCEPTIONS +#endif + +#ifdef wxNO_EXCEPTIONS #define wxTRY #define wxCATCH_ALL(code) -#endif // wxUSE_EXCEPTIONS/!wxUSE_EXCEPTIONS +#else // do use exceptions + #define wxTRY try + #define wxCATCH_ALL(code) catch ( ... ) { code } +#endif // wxNO_EXCEPTIONS/!wxNO_EXCEPTIONS #endif // _WX_EXCEPT_H_ -- 2.47.2