From 0f6c54cdb68e9a228aef5b1b2e3c85a9103251fa Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 11 Nov 2022 01:19:35 +0100 Subject: [PATCH] Define __WXFUNCTION__ as __func__ and don't use it any more Use __func__ without checking if the compiler supports it, it's part of C++11 and so should be supported by all compilers. Also use __func__ instead of __WXFUNCTION__ in our own code. No real changes. --- include/wx/cpp.h | 12 ++---------- include/wx/debug.h | 5 ++--- include/wx/log.h | 2 +- include/wx/qt/private/utils.h | 2 +- include/wx/testing.h | 6 +++--- interface/wx/cpp.h | 8 ++++---- samples/fswatcher/fswatcher.cpp | 2 +- 7 files changed, 14 insertions(+), 23 deletions(-) diff --git a/include/wx/cpp.h b/include/wx/cpp.h index 5f467378b7..3347c1cca4 100644 --- a/include/wx/cpp.h +++ b/include/wx/cpp.h @@ -108,18 +108,10 @@ #define wxDO_IF(condition) wxDO_IF_HELPER(wxMAKE_UNIQUE_NAME(wxdoif), condition) /* - Define __WXFUNCTION__ which is like standard __FUNCTION__ but defined as - nullptr for the compilers which don't support the latter. + This macro is obsolete, use standard __func__ instead. */ #ifndef __WXFUNCTION__ - #if defined(__GNUC__) || \ - defined(__VISUALC__) || \ - defined(__FUNCTION__) - #define __WXFUNCTION__ __FUNCTION__ - #else - /* still define __WXFUNCTION__ to avoid #ifdefs elsewhere */ - #define __WXFUNCTION__ (nullptr) - #endif + #define __WXFUNCTION__ __func__ #endif /* __WXFUNCTION__ already defined */ diff --git a/include/wx/debug.h b/include/wx/debug.h index c82ff5de24..ad38b19959 100644 --- a/include/wx/debug.h +++ b/include/wx/debug.h @@ -15,7 +15,6 @@ #include // for CHAR_BIT used below #include "wx/chartype.h" // for __TFILE__ and wxChar -#include "wx/cpp.h" // for __WXFUNCTION__ #include "wx/dlimpexp.h" // for WXDLLIMPEXP_FWD_BASE class WXDLLIMPEXP_FWD_BASE wxString; @@ -284,7 +283,7 @@ extern WXDLLIMPEXP_BASE void wxOnAssert(const char *file, // A version asserting at the current location. #define wxASSERT_MSG(cond, msg) \ - wxASSERT_MSG_AT(cond, msg, __FILE__, __LINE__, __WXFUNCTION__) + wxASSERT_MSG_AT(cond, msg, __FILE__, __LINE__, __func__) // a version without any additional message, don't use unless condition // itself is fully self-explanatory @@ -307,7 +306,7 @@ extern WXDLLIMPEXP_BASE void wxOnAssert(const char *file, wxFAIL_COND_MSG_AT("Assert failure", msg, file, line, func) #define wxFAIL_COND_MSG(cond, msg) \ - wxFAIL_COND_MSG_AT(cond, msg, __FILE__, __LINE__, __WXFUNCTION__) + wxFAIL_COND_MSG_AT(cond, msg, __FILE__, __LINE__, __func__) #define wxFAIL_MSG(msg) wxFAIL_COND_MSG("Assert failure", msg) #define wxFAIL wxFAIL_MSG((const char*)nullptr) diff --git a/include/wx/log.h b/include/wx/log.h index 0e66721d56..57f1ed89ce 100644 --- a/include/wx/log.h +++ b/include/wx/log.h @@ -1158,7 +1158,7 @@ WXDLLIMPEXP_BASE wxString wxSysErrorMsgStr(unsigned long nErrCode = 0); // creates wxLogger object for the current location #define wxMAKE_LOGGER(level) \ - wxLogger(wxLOG_##level, __FILE__, __LINE__, __WXFUNCTION__, wxLOG_COMPONENT) + wxLogger(wxLOG_##level, __FILE__, __LINE__, __func__, wxLOG_COMPONENT) // this macro generates the expression which logs whatever follows it in // parentheses at the level specified as argument diff --git a/include/wx/qt/private/utils.h b/include/wx/qt/private/utils.h index a91f03bd7d..fecc700ce8 100644 --- a/include/wx/qt/private/utils.h +++ b/include/wx/qt/private/utils.h @@ -22,6 +22,6 @@ void wxMissingImplementation( const char fileName[], unsigned lineNumber, wxMissingImplementation( __FILE__, __LINE__, feature ) #define wxMISSING_FUNCTION() \ - wxMISSING_IMPLEMENTATION( __WXFUNCTION__ ) + wxMISSING_IMPLEMENTATION( __func__ ) #endif // _WX_QT_UTILS_H_ diff --git a/include/wx/testing.h b/include/wx/testing.h index cc9304bf8d..803f0654b8 100644 --- a/include/wx/testing.h +++ b/include/wx/testing.h @@ -429,7 +429,7 @@ protected: wxFAIL_MSG_AT( msg, m_file ? m_file : __FILE__, m_line ? m_line : __LINE__, - m_func ? m_func : __WXFUNCTION__ ); + m_func ? m_func : __func__ ); #else // !__WXDEBUG__ // We still need to report the failure somehow when wx asserts are // disabled. @@ -437,7 +437,7 @@ protected: msg, wxASCII_STR(m_file ? m_file : __FILE__), m_line ? m_line : __LINE__, - wxASCII_STR(m_func ? m_func : __WXFUNCTION__)); + wxASCII_STR(m_func ? m_func : __func__)); #endif // __WXDEBUG__/!__WXDEBUG__ } @@ -517,7 +517,7 @@ private: */ #define wxTEST_DIALOG(codeToRun, ...) \ { \ - wxTEST_DIALOG_HOOK_CLASS wx_hook(__FILE__, __LINE__, __WXFUNCTION__); \ + wxTEST_DIALOG_HOOK_CLASS wx_hook(__FILE__, __LINE__, __func__); \ wxCALL_FOR_EACH(WX_TEST_IMPL_ADD_EXPECTATION, __VA_ARGS__) \ codeToRun; \ wx_hook.CheckUnmetExpectations(); \ diff --git a/interface/wx/cpp.h b/interface/wx/cpp.h index 60f9a1edbb..5a1252aa10 100644 --- a/interface/wx/cpp.h +++ b/interface/wx/cpp.h @@ -48,13 +48,13 @@ #define wxSTRINGIZE_T(x) /** - This macro expands to the name of the current function if the compiler - supports any of @c \__FUNCTION__, @c \__func__ or equivalent variables or - macros or to @NULL if none of them is available. + This obsolete macro is the same as the standard @c \__func__ constant. + + Please use the standard macro instead. @header{wx/cpp.h} */ -#define __WXFUNCTION__ +#define __WXFUNCTION__ __func__ ///@} diff --git a/samples/fswatcher/fswatcher.cpp b/samples/fswatcher/fswatcher.cpp index 85aaeeeed4..818239e4f9 100644 --- a/samples/fswatcher/fswatcher.cpp +++ b/samples/fswatcher/fswatcher.cpp @@ -319,7 +319,7 @@ void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnWatch(wxCommandEvent& event) { - wxLogDebug("%s start=%d", __WXFUNCTION__, event.IsChecked()); + wxLogDebug("%s start=%d", __func__, event.IsChecked()); if (event.IsChecked()) {