My C code is returning a pointer to the structure, this is how I have defined it in python
class CONTEXT(ctypes.Structure):
_fields_ = [
("sockfd", ctypes.c_int),
("eidSeq", ctypes.c_longlong)
]
# API
# connect
PY_connect=NativeDll.gf_connect
# connect input and output parameter declaration
PY_connect.argtype = [
ctypes.c_char_p,
ctypes.c_char_p,
ctypes.POINTER(ctypes.c_int)
]
PY_connect.restype = [
ctypes.POINTER(CONTEXT)
]
But I am getting following error for the restype
TypeError: restype must be a type, a callable, or None
As DaveP already correctly guessed in comments, restype
must not be a list of types.
PY_connect.restype = ctypes.POINTER(CONTEXT)
Note also that argument types are set by the argtypes
attribute, not argtype
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With