mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +00:00
gh-91320: Add _Py_reinterpret_cast() macro (#91959)
Fix C++ compiler warnings about "old-style cast" (g++ -Wold-style-cast) in the Python C API. Use C++ reinterpret_cast<> and static_cast<> casts when the Python C API is used in C++. Example of fixed warning: Include/object.h:107:43: error: use of old-style cast to ‘PyObject*’ {aka ‘struct _object*’} [-Werror=old-style-cast] #define _PyObject_CAST(op) ((PyObject*)(op)) Add _Py_reinterpret_cast() and _Py_static_cast() macros.
This commit is contained in:
parent
f882d33778
commit
29e2245ad5
10 changed files with 42 additions and 17 deletions
|
@ -182,9 +182,9 @@ PyAPI_FUNC(void) PyObject_GC_UnTrack(void *);
|
|||
PyAPI_FUNC(void) PyObject_GC_Del(void *);
|
||||
|
||||
#define PyObject_GC_New(type, typeobj) \
|
||||
( (type *) _PyObject_GC_New(typeobj) )
|
||||
_Py_reinterpret_cast(type*, _PyObject_GC_New(typeobj))
|
||||
#define PyObject_GC_NewVar(type, typeobj, n) \
|
||||
( (type *) _PyObject_GC_NewVar((typeobj), (n)) )
|
||||
_Py_reinterpret_cast(type*, _PyObject_GC_NewVar((typeobj), (n)))
|
||||
|
||||
PyAPI_FUNC(int) PyObject_GC_IsTracked(PyObject *);
|
||||
PyAPI_FUNC(int) PyObject_GC_IsFinalized(PyObject *);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue