define debugging log functions as (empty inline) wxLogNop() instead of nothing in the release builds, this ensures that we have the same code structure in debug/release builds and so there are no bugs when these functions are used inside if/else while also ensuring that even dumbest compilers do remove them completely in release builds
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41090 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -565,16 +565,26 @@ DECLARE_LOG_FUNCTION2(SysError, long, lErrCode);
|
|||||||
// string identifiers
|
// string identifiers
|
||||||
DECLARE_LOG_FUNCTION2(Trace, wxTraceMask, mask);
|
DECLARE_LOG_FUNCTION2(Trace, wxTraceMask, mask);
|
||||||
#else //!debug || !wxUSE_LOG
|
#else //!debug || !wxUSE_LOG
|
||||||
// these functions do nothing in release builds
|
// 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)
|
#define wxVLogDebug(fmt, valist) wxLogNop()
|
||||||
#define wxVLogTrace(mask, fmt, valist)
|
#define wxVLogTrace(mask, fmt, valist) wxLogNop()
|
||||||
|
|
||||||
#ifdef HAVE_VARIADIC_MACROS
|
#ifdef HAVE_VARIADIC_MACROS
|
||||||
// unlike the inline functions below, this completely removes the
|
// unlike the inline functions below, this completely removes the
|
||||||
// wxLogXXX calls from the object file:
|
// wxLogXXX calls from the object file:
|
||||||
#define wxLogDebug(fmt, ...)
|
#define wxLogDebug(fmt, ...) wxLogNop()
|
||||||
#define wxLogTrace(mask, fmt, ...)
|
#define wxLogTrace(mask, fmt, ...) wxLogNop()
|
||||||
#else // !HAVE_VARIADIC_MACROS
|
#else // !HAVE_VARIADIC_MACROS
|
||||||
// note that leaving out "fmt" in the vararg functions provokes a warning
|
// note that leaving out "fmt" in the vararg functions provokes a warning
|
||||||
// from SGI CC: "the last argument of the varargs function is unnamed"
|
// from SGI CC: "the last argument of the varargs function is unnamed"
|
||||||
@@ -612,8 +622,8 @@ wxSafeShowMessage(const wxString& title, const wxString& text);
|
|||||||
#define wxLogLastError(api) wxLogApiError(api, wxSysErrorCode())
|
#define wxLogLastError(api) wxLogApiError(api, wxSysErrorCode())
|
||||||
|
|
||||||
#else //!debug
|
#else //!debug
|
||||||
#define wxLogApiError(api, err)
|
#define wxLogApiError(api, err) wxLogNop()
|
||||||
#define wxLogLastError(api)
|
#define wxLogLastError(api) wxLogNop()
|
||||||
#endif //debug/!debug
|
#endif //debug/!debug
|
||||||
|
|
||||||
// wxCocoa has additiional trace masks
|
// wxCocoa has additiional trace masks
|
||||||
|
Reference in New Issue
Block a user