In <yvals_core.h>, the STL's central internal header, we define internal helper macros for temporarily suppressing [[deprecated]] warnings:
|
// clang-format off |
|
#ifndef _STL_DISABLE_DEPRECATED_WARNING |
|
#ifdef __clang__ |
|
#define _STL_DISABLE_DEPRECATED_WARNING \ |
|
_Pragma("clang diagnostic push") \ |
|
_Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") |
|
#else // __clang__ |
|
#define _STL_DISABLE_DEPRECATED_WARNING \ |
|
__pragma(warning(push)) \ |
|
__pragma(warning(disable : 4996)) // was declared deprecated |
|
#endif // __clang__ |
|
#endif // _STL_DISABLE_DEPRECATED_WARNING |
|
// clang-format on |
|
|
|
#ifndef _STL_RESTORE_DEPRECATED_WARNING |
|
#ifdef __clang__ |
|
#define _STL_RESTORE_DEPRECATED_WARNING _Pragma("clang diagnostic pop") |
|
#else // __clang__ |
|
#define _STL_RESTORE_DEPRECATED_WARNING __pragma(warning(pop)) |
|
#endif // __clang__ |
|
#endif // _STL_RESTORE_DEPRECATED_WARNING |
For Clang, this uses Standard _Pragma to emit a #pragma directive within a macro. For MSVC, this uses non-Standard __pragma.
Our general rule is to avoid non-Standard extensions unless they're necessary. As of VS 2019 16.6 Preview 2, which the STL now requires, MSVC supports Standard _Pragma, so we should use it here. (We still need #ifdef __clang__ logic because Clang and MSVC need different syntax to suppress the [[deprecated]] warning.)
Note: Standard _Pragma takes a string while non-Standard __pragma doesn't, as the existing code demonstrates.
In
<yvals_core.h>, the STL's central internal header, we define internal helper macros for temporarily suppressing[[deprecated]]warnings:STL/stl/inc/yvals_core.h
Lines 448 to 468 in 811c8c1
For Clang, this uses Standard
_Pragmato emit a#pragmadirective within a macro. For MSVC, this uses non-Standard__pragma.Our general rule is to avoid non-Standard extensions unless they're necessary. As of VS 2019 16.6 Preview 2, which the STL now requires, MSVC supports Standard
_Pragma, so we should use it here. (We still need#ifdef __clang__logic because Clang and MSVC need different syntax to suppress the[[deprecated]]warning.)Note: Standard
_Pragmatakes a string while non-Standard__pragmadoesn't, as the existing code demonstrates.