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.
This commit is contained in:
Vadim Zeitlin 2022-11-11 01:19:35 +01:00
parent cf01a2827b
commit 0f6c54cdb6
7 changed files with 14 additions and 23 deletions

View file

@ -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 */

View file

@ -15,7 +15,6 @@
#include <limits.h> // 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)

View file

@ -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

View file

@ -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_

View file

@ -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(); \

View file

@ -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__
///@}

View file

@ -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())
{