]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-91320: Add _Py_reinterpret_cast() macro (#91959)
authorVictor Stinner <vstinner@python.org>
Wed, 27 Apr 2022 08:40:57 +0000 (10:40 +0200)
committerGitHub <noreply@github.com>
Wed, 27 Apr 2022 08:40:57 +0000 (10:40 +0200)
commit29e2245ad5d28b565fe0d0d667d283708c6e832c
tree8147203346a87146036c0087893f910409d886b0
parentf882d33778ee2625ab32d90e28edb6878fb8af93
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.
Include/cpython/abstract.h
Include/cpython/listobject.h
Include/cpython/methodobject.h
Include/cpython/tupleobject.h
Include/cpython/unicodeobject.h
Include/methodobject.h
Include/object.h
Include/objimpl.h
Include/pyport.h
Misc/NEWS.d/next/C API/2022-04-26-16-51-31.gh-issue-91320.QDHmTv.rst [new file with mode: 0644]