-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
bpo-43816: add 'extern "C"' to pyctype.h #25365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Andrew V. Jones <andrew.jones@vector.com>
Signed-off-by: Andrew V. Jones <andrew.jones@vector.com>
Any idea why |
Thanks @andrewvaughanj for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8. |
Thanks @andrewvaughanj for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9. |
Sorry @andrewvaughanj and @vstinner, I had trouble checking out the |
GH-25386 is a backport of this pull request to the 3.8 branch. |
Signed-off-by: Andrew V. Jones <andrew.jones@vector.com> (cherry picked from commit 54db51c) Co-authored-by: Andrew V. Jones <andrewvaughanj@gmail.com>
Thanks @andrewvaughanj for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9. |
GH-25387 is a backport of this pull request to the 3.9 branch. |
Signed-off-by: Andrew V. Jones <andrew.jones@vector.com> (cherry picked from commit 54db51c) Co-authored-by: Andrew V. Jones <andrewvaughanj@gmail.com>
Issue
With Python 3.9.4, and when compiling with Visual Studio 2019, we have noticed that the variable
_Py_ctype_table
is not scoped with in anextern "C"
block, and where the Python library (python39.lib
) has been compiled with a C compiler.This causes an issue when trying to refer to
_Py_ctype_table
from a C++ file, as the compiler tries to name-mangle the use of_Py_ctype_table
, but the linker cannot then tie the mangled name to non-mangled named frompython39.lib
.Example:
Compilation:
With
cl.exe
:A naïve check of Python.h (e126547) seems to suggest that:
extern "C"
extern "C"
For the 8 that do not contain
extern "C"
, none of these usePyAPI_DATA
. This leads me to believe that it is an oversight thatpyctype.h
does not haveextern "C"
Resolution
This PR resolves this issue by adding an
extern "C"
declaration to the top ofpyctype.h
(if compiling as C++).Signed-off-by: Andrew V. Jones andrew.jones@vector.com
https://bugs.python.org/issue43816