bpo-19569: Add a macro to suppress deprecation warnings (GH-9004) · python/cpython@de4304d (original) (raw)

File tree

2 files changed

lines changed

2 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -515,6 +515,26 @@ extern "C" {
515 515 #define Py_DEPRECATED(VERSION_UNUSED)
516 516 #endif
517 517
518 +#if defined(__clang__)
519 +#define _Py_COMP_DIAG_PUSH _Pragma("clang diagnostic push")
520 +#define _Py_COMP_DIAG_IGNORE_DEPR_DECLS \
521 + _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
522 +#define _Py_COMP_DIAG_POP _Pragma("clang diagnostic pop")
523 +#elif defined(__GNUC__) \
524 +&& ((__GNUC__ >= 5) |
525 +#define _Py_COMP_DIAG_PUSH _Pragma("GCC diagnostic push")
526 +#define _Py_COMP_DIAG_IGNORE_DEPR_DECLS \
527 + _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
528 +#define _Py_COMP_DIAG_POP _Pragma("GCC diagnostic pop")
529 +#elif defined(_MSC_VER)
530 +#define _Py_COMP_DIAG_PUSH __pragma(warning(push))
531 +#define _Py_COMP_DIAG_IGNORE_DEPR_DECLS __pragma(warning(disable: 4996))
532 +#define _Py_COMP_DIAG_POP __pragma(warning(pop))
533 +#else
534 +#define _Py_COMP_DIAG_PUSH
535 +#define _Py_COMP_DIAG_IGNORE_DEPR_DECLS
536 +#define _Py_COMP_DIAG_POP
537 +#endif
518 538
519 539 /* _Py_HOT_FUNCTION
520 540 * The hot attribute on a function is used to inform the compiler that the
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1 +Add the private macros ``_Py_COMP_DIAG_PUSH``,
2 +``_Py_COMP_DIAG_IGNORE_DEPR_DECLS``, and ``_Py_COMP_DIAG_POP``.