You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
What way to choose to fix Warning: ULONG_PTR differs in levels of indirection from void * in AC-generated code? #95417
Currently, Argument Clinic generates initialization of ULONG_PTR arguments using PyLong_AsVoidPtr(). The reason is sizeof(ULONG_PTR) == sizeof(void*) akin to C99 uintptr_t.
However, a compiler warns that implicit conversion of a pointer to a pointer-sized integer is not the best practice. This is relevant for _overlapped.CreateIoCompletionPort():
generate in-place cast: CompletionKey = (ULONG_PTR)PyLong_AsVoidPtr(args[2]); or
add a private Windows-only #define _PyLong_AsUlongPtr(arg) (ULONG_PTR)PyLong_AsVoidPtr(arg) macro so the generated line becomes CompletionKey = PyLong_AsUlongPtr(args[2]); or
add a public Windows-only PyLong_AsUlongPtr entity and document it so Python integrators and module authors also can work with this volatile WinAPI type
The C API could support cross-platform PyLong_AsUintptr_t() and PyLong_FromUintptr_t(). The type definitions for ULONG_PTR and uintptr_t are compatible in Windows. For 64-bit, they're both unsigned __int64. For 32-bit, uintptr_t is unsigned int, and ULONG_PTR is unsigned long.
Activity
eryksun commentedon Jul 29, 2022
The C API could support cross-platform
PyLong_AsUintptr_t()andPyLong_FromUintptr_t(). The type definitions forULONG_PTRanduintptr_tare compatible in Windows. For 64-bit, they're bothunsigned __int64. For 32-bit,uintptr_tisunsigned int, andULONG_PTRisunsigned long.arhadthedev commentedon Aug 1, 2022
To fix the warning, two steps are necessary:
PyLong_FromUintptr_tandPyLong_AsUintptr_t#95446 (deciding first whetherPyLong_*Uintptr_tshould be a macro/inline function or exported from python3.dll/.so)ULONG_PTR differs in levels of indirection from void *#95518gh-95417: Quick fix for "ULONG_PTR differs in levels of indirection f…
arhadthedev commentedon Feb 5, 2023
According to https://devguide.python.org/developer-workflow/c-api/#guidelines-for-adding-to-the-limited-api, addition of stable ABI requires long discussion. I'm not ready for this for the sake of a single use case so closing this issue.