Re: [ctypes-users] cast pointer to long ?
Brought to you by:
theller
From: Luke D. <cod...@ho...> - 2006-05-27 03:13:43
|
----- Original Message ----- From: "Simon Burton" <si...@ar...> To: <cty...@li...> Sent: Saturday, May 27, 2006 9:44 AM Subject: [ctypes-users] cast pointer to long ? > > Does ctypes support casting a pointer to a long ? No, but if you cast it to c_void_p first then you can extract the integer value: >>> ctypes.cast( func_ptr, ctypes.c_void_p ) c_void_p(2088770935) >>> ctypes.cast( func_ptr, ctypes.c_void_p ).value 2088770935 >>> Luke >>>> ctypes.cast( func_ptr, ctypes.c_long ) > Traceback (most recent call last): > File "<stdin>", line 1, in ? > File "/home/users/simonb/lib/python2.3/site-packages/ctypes/__init__.py", > line 432, in cast > return _cast(obj, obj, typ) > TypeError: cast() argument 2 must be a pointer type, not c_long >>>> > > Simon. > > -- > Simon Burton, B.Sc. > Licensed PO Box 8066 > ANU Canberra 2601 > Australia > Ph. 61 02 6249 6940 > http://arrowtheory.com |