Merge branch 'std-deprecated-attr'
Add wxDEPRECATED_ATTR expanding to the standard C++14 [[deprecated]] attribute.
This commit is contained in:
@@ -171,6 +171,8 @@ Currently the following symbols exist:
|
||||
wxBitmapToggleButton class is available in addition to wxToggleButton.}
|
||||
@itemdef{wxHAS_CONFIG_TEMPLATE_RW, Defined if the currently used compiler
|
||||
supports template Read() and Write() methods in wxConfig.}
|
||||
@itemdef{wxHAS_DEPRECATED_ATTR, Defined if C++14 @c [[deprecated]] attribute is
|
||||
supported (this symbol only exists in wxWidgets 3.1.6 or later).}
|
||||
@itemdef{wxHAS_MEMBER_DEFAULT, Defined if the currently used compiler supports
|
||||
C++11 @c =default.}
|
||||
@itemdef{wxHAS_LARGE_FILES, Defined if wxFile supports files more than 4GB in
|
||||
|
@@ -573,14 +573,29 @@ typedef short int WXTYPE;
|
||||
/*
|
||||
Macros for marking functions as being deprecated.
|
||||
|
||||
The preferred macro in the new code is wxDEPRECATED_MSG() which allows to
|
||||
explain why is the function deprecated. Almost all the existing code uses
|
||||
the older wxDEPRECATED() or its variants currently, but this will hopefully
|
||||
change in the future.
|
||||
The preferred macro in the new code is wxDEPRECATED_ATTR() which expands to
|
||||
the standard [[deprecated]] attribute if supported and allows to explain
|
||||
why is the function deprecated. If supporting older compilers is important,
|
||||
wxDEPRECATED_MSG() can be used as it's almost universally available and
|
||||
still allows to explain the reason for the deprecation.
|
||||
|
||||
However almost all the existing code uses the older wxDEPRECATED() or its
|
||||
variants currently, but this will hopefully change in the future.
|
||||
*/
|
||||
|
||||
#if defined(__has_cpp_attribute)
|
||||
#if __has_cpp_attribute(deprecated)
|
||||
/* gcc 5 claims to support this attribute, but actually doesn't */
|
||||
#if !defined(__GNUC__) || wxCHECK_GCC_VERSION(6, 0)
|
||||
#define wxHAS_DEPRECATED_ATTR
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* The basic compiler-specific construct to generate a deprecation warning. */
|
||||
#ifdef __clang__
|
||||
#ifdef wxHAS_DEPRECATED_ATTR
|
||||
#define wxDEPRECATED_DECL [[deprecated]]
|
||||
#elif defined(__clang__)
|
||||
#define wxDEPRECATED_DECL __attribute__((deprecated))
|
||||
#elif defined(__GNUC__)
|
||||
#define wxDEPRECATED_DECL __attribute__((deprecated))
|
||||
@@ -590,13 +605,28 @@ typedef short int WXTYPE;
|
||||
#define wxDEPRECATED_DECL
|
||||
#endif
|
||||
|
||||
#ifdef wxHAS_DEPRECATED_ATTR
|
||||
#define wxDEPRECATED_ATTR(msg) [[deprecated(msg)]]
|
||||
#else
|
||||
/*
|
||||
Note that we can't fall back on wxDEPRECATED_DECL here, as the standard
|
||||
attribute works in places where the compiler-specific one don't,
|
||||
notably it can be used after enumerator declaration with MSVC, while
|
||||
__declspec(deprecated) can't occur there as it can only be used before
|
||||
the declaration.
|
||||
*/
|
||||
#define wxDEPRECATED_ATTR(msg)
|
||||
#endif
|
||||
|
||||
/*
|
||||
Macro taking the deprecation message. It applies to the next declaration.
|
||||
|
||||
If the compiler doesn't support showing the message, this degrades to a
|
||||
simple wxDEPRECATED(), i.e. at least gives a warning, if possible.
|
||||
*/
|
||||
#if defined(__clang__) && defined(__has_extension)
|
||||
#ifdef wxHAS_DEPRECATED_ATTR
|
||||
#define wxDEPRECATED_MSG(msg) [[deprecated(msg)]]
|
||||
#elif defined(__clang__) && defined(__has_extension)
|
||||
#if __has_extension(attribute_deprecated_with_message)
|
||||
#define wxDEPRECATED_MSG(msg) __attribute__((deprecated(msg)))
|
||||
#else
|
||||
|
@@ -1600,6 +1600,17 @@ template <typename T> void wxDELETE(T*& ptr);
|
||||
*/
|
||||
template <typename T> void wxDELETEA(T*& array);
|
||||
|
||||
/**
|
||||
Expands to the standard C++14 [[deprecated]] attribute if supported.
|
||||
|
||||
If not supported by the compiler, expands to nothing. If support for such
|
||||
compilers is important, use wxDEPRECATED_MSG() which is almost universally
|
||||
available.
|
||||
|
||||
@since 3.1.6
|
||||
*/
|
||||
#define wxDEPRECATED_ATTR(msg) [[deprecated(msg)]]
|
||||
|
||||
/**
|
||||
Generate deprecation warning with the given message when a function is
|
||||
used.
|
||||
|
Reference in New Issue
Block a user