Add __WXFUNCTION_SIG__ macro

If compiling as C++20 or using GCC or MSVC, expands to function
signature. Falls back to the function name (__func__) otherwise.

Closes #24554.
This commit is contained in:
Blake-Madden
2024-05-28 18:53:01 +02:00
committed by Vadim Zeitlin
parent bb85ffa042
commit f1c501086e
2 changed files with 41 additions and 0 deletions
+18
View File
@@ -114,6 +114,24 @@
#define __WXFUNCTION__ __func__
#endif /* __WXFUNCTION__ already defined */
/*
Expands to the current function's full signature, if available.
Falls back to the function name (i.e., __func__) if not available.
*/
#ifndef __WXFUNCTION_SIG__
#if __cplusplus >= 202002L
#include <source_location>
// actually displays the signature, not just the name
#define __WXFUNCTION_SIG__ std::source_location::current().function_name()
#elif defined(__VISUALC__)
#define __WXFUNCTION_SIG__ __FUNCSIG__
#elif defined(__GNUG__)
#define __WXFUNCTION_SIG__ __PRETTY_FUNCTION__
#else
#define __WXFUNCTION_SIG__ __func__
#endif
#endif /* __WXFUNCTION_SIG__ already defined */
/*
wxCALL_FOR_EACH(what, ...) calls the macro from its first argument, what(pos, x),
+23
View File
@@ -52,9 +52,32 @@
Please use the standard macro instead.
@see __WXFUNCTION_SIG__
@header{wx/cpp.h}
*/
#define __WXFUNCTION__ __func__
/**
Expands to the current function's full signature, if available.
Falls back to the function name (i.e., @c \__func__) if not available.
As an example, if you have a class named `Calculator` with a
`double Add(double, double) const` member function,
`__WXFUNCTION_SIG__` may expand to the following:
`double Calculator::Add(double, double) const`
While `__func__` will simply expand to:
`Add`
@header{wx/cpp.h}
@since 3.3.0
*/
#define __WXFUNCTION_SIG__
///@}