Expected LP_c_double instance instead of c_double_Array - python ctypes error

后端 未结 2 1302
情话喂你
情话喂你 2021-01-20 07:30

I have a function in a DLL that I have to wrap with python code. The function is expecting a pointer to an array of doubles. This is the error I\'m getting:

         


        
2条回答
  •  误落风尘
    2021-01-20 08:20

    Are you writing the wrapper in Python yourself? The error saying "expected LP_c_double instance" means it's expecting a pointer to a single double, not an array as you've suggested.

    >>> ctypes.POINTER(ctypes.c_double * 10)()
    <__main__.LP_c_double_Array_10 object at 0xb7eb24f4>
    >>> ctypes.POINTER(ctypes.c_double * 20)()
    <__main__.LP_c_double_Array_20 object at 0xb7d3a194>
    >>> ctypes.POINTER(ctypes.c_double)()
    <__main__.LP_c_double object at 0xb7eb24f4>
    

    Either you need to fix your argtypes to correctly expect a pointer to an array of doubles, or you need to pass in a pointer to a single double like the function currently expects.

提交回复
热议问题