I am using the ctypes at python3.8 to call C++ function, the function parameter is an array, and its returns to an array as well. So I create the python list first, then convert it to C++ array to call the function.
ll = ctypes.cdll.LoadLibrary
lib = ll('./ct.so')
nums = [0, 1, 2, 3]
arr = (ctypes.c_int * len(nums))(*nums)
nums2 = lib.method01(arr)
As you can see, nums is a python list, and I convert it to C++ array by using ctypes, get arr. Then I get a C++ array nums2 by calling lib.method01(arr).
Since nums2 is a C++ array, so the print(nums2) get the result like this: __main__.c_int_Array_4, which is not a python array. So is there anything can do to transfer c++ array to python array?
Thanks