Unsigned pointer in python

I am working on python and ctypes

for python.

I want to convert a given number to ctypes.c_uint32

and then access its pointer like this:

d = 0
d_c_unit32 = (ctypes.c_uint32 * 1)(d)
pd_c = ctypes.POINTER(d_c_unit32)

      

but I have an error that says:

Verbose TypeError: Must be of type ctypes

please tell me where is the problem?

+3


source to share


1 answer


d = 0
num = ctypes.c_uint32(d)
ptr = ctypes.pointer(num)
print 'pointer:', ptr
print 'value:', ptr[0]

      

Output:



pointer: <__main__.LP_c_uint object at 0x7f4551c27680>
value: 0

      

+3


source







All Articles