ctypes from_param() truncating 64 bit pointers to 32 bit

Stefan Behnel stefan_ml at behnel.de
Fri Feb 18 03:39:10 EST 2011

Joakim Hove, 18.02.2011 09:29:
> I wonder if I am encountering a bug in ctypes; or if I am doing things
> wrong? I have written a small Python class wrapping a C library, the
> Python class has a from_param() method which passes a "raw pointer
> value" from Python to C. When reaching C the pointer has been
> truncated to 32 bits.
> I have written a quite extensive post about this on Stackoverflow:
> http://www.stackoverflow.com/q/5029341/421889/ - so far without
> response. Would have been very glad if anyone could indicate if this
> was a bug on my part, or if it is a ctypes bug.

I rarely use ctypes and I actually don't know how this specific case works. 
However, you are not providing a function signature for the "print_addr" C 
function in the BugTest case, so my guess is that it assumes the standard 
signature for C functions, which is "int func(int)". That would explain the 
32bit truncation.


More information about the Python-list mailing list