Given the following C function from a library I want to link to:
    
    
    typedef void (*fptr_f) (double, double *, double *, void *);
    void foo(_fptr_f f,  double *y, void *_data);
    
    
    Run

I have written the following Nim equivalent:
    
    
    type fptr_f = proc(t: cdouble, y: ptr cdouble, ydot: ptr cdouble, data: 
pointer): void {.cdecl.}
    proc foo(f: fptr_f, y: ptr cdouble, data: pointer): void {.importc: 
"lsoda".}
    
    
    Run

How do I write the following C function in Nim and pass it to the proc foo in 
Nim?
    
    
    static void fex(double t, double *y, double *ydot, void *data)
    {
            ydot[0] = 1.0E4 * y[1] * y[2] - .04E0 * y[0];
            ydot[2] = 3.0E7 * y[1] * y[1];
            ydot[1] = -1.0 * (ydot[0] + ydot[2]);
    }
    
    
    Run

Reply via email to