X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/655719367ac5e131d9642e5783f3ecf64d1a3385..ae8079a2109cc4cfe27fe5de16679726dd7660ca:/include/wx/except.h diff --git a/include/wx/except.h b/include/wx/except.h index 0fb5ae4aff..116a82efbc 100644 --- a/include/wx/except.h +++ b/include/wx/except.h @@ -18,13 +18,24 @@ // 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)) + #ifndef wxNO_EXCEPTIONS + #define wxNO_EXCEPTIONS + #endif +#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_