What way to choose to fix Warning: ULONG_PTR differs in levels of indirection from void * in AC-generated code?
#95417
Labels
type-feature
A feature request or enhancement
arhadthedev commentedJul 29, 2022
•
edited
Currently, Argument Clinic generates initialization of
ULONG_PTRarguments usingPyLong_AsVoidPtr(). The reason issizeof(ULONG_PTR) == sizeof(void*)akin to C99uintptr_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
cpython/Modules/clinic/overlapped.c.h
Line 40 in 3e7cad3
I see three ways to fix it in
ULONG_PTRArgument Clinic converter and need an opinion on how to address the warning best:CompletionKey = (ULONG_PTR)PyLong_AsVoidPtr(args[2]);or#define _PyLong_AsUlongPtr(arg) (ULONG_PTR)PyLong_AsVoidPtr(arg)macro so the generated line becomesCompletionKey = PyLong_AsUlongPtr(args[2]);orPyLong_AsUlongPtrentity and document it so Python integrators and module authors also can work with this volatile WinAPI typeLinked PRs
The text was updated successfully, but these errors were encountered: