X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2e7f384517ccb08cec87dd233c8f11f876b65e5c..2bf8f4c0d57be03ee27a0f84d041ebcb99202497:/include/wx/log.h diff --git a/include/wx/log.h b/include/wx/log.h index 0e548d2bbe..164bdfca90 100644 --- a/include/wx/log.h +++ b/include/wx/log.h @@ -565,16 +565,33 @@ DECLARE_LOG_FUNCTION2(SysError, long, lErrCode); // string identifiers DECLARE_LOG_FUNCTION2(Trace, wxTraceMask, mask); #else //!debug || !wxUSE_LOG - // these functions do nothing in release builds - - // note that leaving out "fmt" in the vararg functions provokes a warning - // from SGI CC: "the last argument of the varargs function is unnamed" - inline void wxVLogDebug(const wxChar *, va_list) { } - inline void wxLogDebug(const wxChar *fmt, ...) { wxUnusedVar(fmt); } - inline void wxVLogTrace(wxTraceMask, const wxChar *, va_list) { } - inline void wxLogTrace(wxTraceMask, const wxChar *fmt, ...) { wxUnusedVar(fmt); } - inline void wxVLogTrace(const wxChar *, const wxChar *, va_list) { } - inline void wxLogTrace(const wxChar *, const wxChar *fmt, ...) { wxUnusedVar(fmt); } + // these functions do nothing in release builds, but don't define them as + // nothing as it could result in different code structure in debug and + // release and this could result in trouble when these macros are used + // inside if/else + // + // note that making wxVLogDebug/Trace() themselves (empty inline) functions + // is a bad idea as some compilers are stupid enough to not inline even + // empty functions if their parameters are complicated enough, but by + // defining them as an empty inline function we ensure that even dumbest + // compilers optimise them away + inline void wxLogNop() { } + + #define wxVLogDebug(fmt, valist) wxLogNop() + #define wxVLogTrace(mask, fmt, valist) wxLogNop() + + #ifdef HAVE_VARIADIC_MACROS + // unlike the inline functions below, this completely removes the + // wxLogXXX calls from the object file: + #define wxLogDebug(fmt, ...) wxLogNop() + #define wxLogTrace(mask, fmt, ...) wxLogNop() + #else // !HAVE_VARIADIC_MACROS + // note that leaving out "fmt" in the vararg functions provokes a warning + // from SGI CC: "the last argument of the varargs function is unnamed" + inline void wxLogDebug(const wxChar *fmt, ...) { wxUnusedVar(fmt); } + inline void wxLogTrace(wxTraceMask, const wxChar *fmt, ...) { wxUnusedVar(fmt); } + inline void wxLogTrace(const wxChar *, const wxChar *fmt, ...) { wxUnusedVar(fmt); } + #endif // HAVE_VARIADIC_MACROS/!HAVE_VARIADIC_MACROS #endif // debug/!debug // wxLogFatalError helper: show the (fatal) error to the user in a safe way, @@ -605,8 +622,8 @@ wxSafeShowMessage(const wxString& title, const wxString& text); #define wxLogLastError(api) wxLogApiError(api, wxSysErrorCode()) #else //!debug - inline void wxLogApiError(const wxChar *, long) { } - inline void wxLogLastError(const wxChar *) { } + #define wxLogApiError(api, err) wxLogNop() + #define wxLogLastError(api) wxLogNop() #endif //debug/!debug // wxCocoa has additiional trace masks