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 c_i, int iterations, double limit)
It reconfigures the custom structure, which consists of a three-double array:
struct res { double arr[3]; };
To return the values, I do this:
struct res result; result.arr[0] = z_real; result.arr[1] = z_imag; result.arr[2] = value; return result;
I compiled it using MinGW, and I'm trying to use it in python to do something like this:
form ctypes import * z = [0.0,0.0] c = [1.0,1.0] M = 2.0 MiDLL = WinDLL("RECERCATOOLS.dll") MiDLL.ITERATE.argtypes = [c_double, c_double, c_double, c_double,c_int,c_double] MiDLL.ITERATE(z[0],z[1],c[0],c[1],100,M)
But, whenever I try to call a function with these values, it will throw me:
WindowsError: exception: access violation writing 0x00000000
I also donβt know how to catch the custom structure that I declared and convert each of its elements to Python floating points. I looked at this PyDocs link , but to no avail.
Thanks in advance.
EDIT:
This is the original (modified as suggested) header used ("mydll.h"):
#ifndef MYDLL_H #define MYDLL_H extern "C" __declspec(dllexport) #define EXPORT_DLL __declspec(dllexport) EXPORT_DLL void ITERATE(struct res*, double z_r,double z_i,double c_r, double c_i, int iterations, double limit) #endif
And, if something may be wrong with it, the code file (it is very short, only one function):
#include <stdio.h>