Error when using ctypes module to acess a DLL written in C

后端 未结 1 1164
滥情空心
滥情空心 2020-12-20 07:42

I have a DLL with one single function That gets five doubles and one int:

__declspec(dllexport)  struct res ITERATE(double z_r,double z_i,double c_r, double          


        
1条回答
  •  生来不讨喜
    2020-12-20 07:57

    There is a problem with returning structs like that. Not all compilers return such structures the same way. I'd rather change the function declaration to this:

    void __declspec(dllexport) ITERATE(struct res* result, double z_r,double z_i, 
        double c_r, double c_i, int iterations, double limit);
    

    That way the struct is in the user's memory, and there is no ambiguity on how the struct will be returned.

    Of course, as David said, you may have to use a different calling convention.

    0 讨论(0)
提交回复
热议问题