From: Vadim Zeitlin Date: Thu, 5 Sep 2013 14:10:34 +0000 (+0000) Subject: Revert wxDO_LOG_IF_ENABLED() change for MSVC6 in r74735. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/ff701a5de90478a656e7e8b6236d239d8cccd6b3?ds=inline Revert wxDO_LOG_IF_ENABLED() change for MSVC6 in r74735. The old solution worked fine for that compiler and the new one fails when wxLogXXX() is used inside a switch statement to the wrong rules used by VC6 for the scope of the variables defined inside the for loop. Simply revert back to using the old version for it, this will be easy to re-revert after 3.0 by simply removing the check for it. See #11829. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74762 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/log.h b/include/wx/log.h index fbe855b009..be0a245a49 100644 --- a/include/wx/log.h +++ b/include/wx/log.h @@ -1342,6 +1342,21 @@ WXDLLIMPEXP_BASE const wxChar* wxSysErrorMsg(unsigned long nErrCode = 0); // // See also #11829 for the problems with other simpler approaches, // notably the need for two macros due to buggy __LINE__ in MSVC. +// +// Note 2: Unfortunately we can't use the same solution for all compilers +// because the loop-based one results in problems with MSVC6 due to its +// wrong (pre-C++98) rules for the scope of the variables declared +// inside the loop, as this prevents us from using wxLogXXX() in switch +// statement clauses ("initialization of loopvar skipped by case"). So +// for now, i.e. while we still support VC6, use the previous solution +// for it (FIXME-VC6). +#ifdef __VISUALC6__ +#define wxDO_LOG_IF_ENABLED(level) \ + if ( !wxLog::IsLevelEnabled(wxLOG_##level, wxLOG_COMPONENT) ) \ + {} \ + else \ + wxDO_LOG(level) +#else #define wxDO_LOG_IF_ENABLED_HELPER(level, loopvar) \ for ( bool loopvar = false; \ !loopvar && wxLog::IsLevelEnabled(wxLOG_##level, wxLOG_COMPONENT); \ @@ -1350,6 +1365,7 @@ WXDLLIMPEXP_BASE const wxChar* wxSysErrorMsg(unsigned long nErrCode = 0); #define wxDO_LOG_IF_ENABLED(level) \ wxDO_LOG_IF_ENABLED_HELPER(level, wxMAKE_UNIQUE_NAME(wxlogcheck)) +#endif // wxLogFatalError() is special as it can't be disabled #define wxLogFatalError wxDO_LOG(FatalError)