-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
Closed as not planned
Closed as not planned
Copy link
Labels
type-featureA feature request or enhancementA feature request or enhancement
Description
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()
:
cpython/Modules/clinic/overlapped.c.h
Lines 15 to 18 in 3e7cad3
_overlapped_CreateIoCompletionPort_impl(PyObject *module, HANDLE FileHandle, | |
HANDLE ExistingCompletionPort, | |
ULONG_PTR CompletionKey, | |
DWORD NumberOfConcurrentThreads); |
cpython/Modules/clinic/overlapped.c.h
Line 40 in 3e7cad3
CompletionKey = PyLong_AsVoidPtr(args[2]); |
I see three ways to fix it in ULONG_PTR
Argument Clinic converter and need an opinion on how to address the warning best:
- 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 becomesCompletionKey = 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
Linked PRs
Metadata
Metadata
Assignees
Labels
type-featureA feature request or enhancementA feature request or enhancement