Skip to content

Commit de4304d

Browse files
bpo-19569: Add a macro to suppress deprecation warnings (GH-9004)
Co-authored-by: Arfrever Frehtes Taifersar Arahesis <arfrever.fta@gmail.com>
1 parent 113e2b0 commit de4304d

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

Include/pyport.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,26 @@ extern "C" {
515515
#define Py_DEPRECATED(VERSION_UNUSED)
516516
#endif
517517

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) || (__GNUC__ == 4) && (__GNUC_MINOR__ >= 6))
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
518538

519539
/* _Py_HOT_FUNCTION
520540
* The hot attribute on a function is used to inform the compiler that the
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff 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``.

0 commit comments

Comments
 (0)