[issue19569] Use __attribute__((deprecated)) to warn usage of deprecated functions and macros
Arfrever Frehtes Taifersar Arahesis
report at bugs.python.org
Sun Nov 6 12:21:38 EST 2016
Arfrever Frehtes Taifersar Arahesis added the comment:
_Pragma syntax would be more suitable since it could be used with macros:
https://gcc.gnu.org/onlinedocs/gcc-6.2.0/cpp/Pragmas.html
Then Include/pyport.h (which defines Py_DEPRECATED) could also define:
#if defined(__GNUC__) && ((__GNUC__ >= 5) || (__GNUC__ == 4) && (__GNUC_MINOR__ >= 6))
#define Py_COMPILER_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
#define Py_COMPILER_DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
#define Py_COMPILER_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
#else
#define Py_COMPILER_DIAGNOSTIC_PUSH
#define Py_COMPILER_DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS
#define Py_COMPILER_DIAGNOSTIC_POP
#endif
These macros would be used in this way:
void some_function(void)
{
int x, y;
Py_COMPILER_DIAGNOSTIC_PUSH
Py_COMPILER_DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS
x = some_deprecated_function();
Py_COMPILER_DIAGNOSTIC_POP
y = x + 1;
}
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19569>
_______________________________________
More information about the Python-bugs-list
mailing list