-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Labels
enhancementSomething can be improvedSomething can be improvedfixedSomething works now, yay!Something works now, yay!
Description
In <yvals_core.h>, the STL's central internal header, we define internal helper macros for temporarily suppressing [[deprecated]] warnings:
Lines 448 to 468 in 811c8c1
| // 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.
Metadata
Metadata
Assignees
Labels
enhancementSomething can be improvedSomething can be improvedfixedSomething works now, yay!Something works now, yay!