ctypes struct returned from library
问题 Given a simple C file: #include <stdio.h> typedef struct point { int x; int y; } POINT; POINT get_point() { POINT p = {1, 2}; return p; } And I have a simple python file: from ctypes import * import os lib_name = '/testlib.so' test_lib = CDLL(os.getcwd() + lib_name) class POINT(Structure): _fields_ = [('x', c_int), ('y', c_int)] # Sets p1 to the integer 1 p1 = test_lib.get_point() # Sets p2 to the struct POINT with values {1, 0} p2 = POINT(test_lib.get_point()) How can I set my returned value