gh-144490: Fix C++ compatibility in pycore_cell.h#144482
gh-144490: Fix C++ compatibility in pycore_cell.h#144482yoney wants to merge 1 commit intopython:mainfrom
Conversation
|
Do we do this kind of stuff for every calls? do we support |
|
The internal headers ( The change itself seems fine, but I'm curious how this came up. What's including |
|
To answer @picnixz, we generally do this sort of thing when people ask, especially when the changes are tiny, but we don't proactively make the internal header files C++ compatible. |
This came up while I’m adapting CinderX to FT-Python: C++ codegen path for Also agreed that |
|
Ok, make sense. Can you open an issue like @picnixz asked? Also edit the PR title to associate it with the issue. |
|
Created the issue #144490 @picnixz, @colesbury: Thank you so much for the review. |
ZeroIntensity
left a comment
There was a problem hiding this comment.
Please also add an #include to test_cppext as well, like this:
cpython/Lib/test/test_cppext/extension.cpp
Lines 15 to 19 in b6d8aa4
That'll make sure we don't break this again someday.
| PyObject *value; | ||
| #ifdef Py_GIL_DISABLED | ||
| value = _Py_atomic_load_ptr(&cell->ob_ref); | ||
| value = (PyObject *)_Py_atomic_load_ptr(&cell->ob_ref); |
There was a problem hiding this comment.
Up to you, but I believe we've used _Py_STATIC_CAST for things like this in the past. That will expand to static_cast<type>(expr) in C++, and then the usual (type)(expr) in C.
The header already includes an
extern "C"guard, suggesting it is intended to be C++ compatible. Adding a cast allows it to compile without-fpermissive.cc: @colesbury