Passing a Julia function to C, with a double* input argument

Hello,

I have to pass a Julia function to C. The C function has one input argument: a double*.

For example

function myfun(x)
  return sum(x)
end

What is the way? Is it that:

myfun_c = @cfunction(myfun, Cdouble, (Ref{Ptr{Cdouble}}, ))

?

Thank you.

I get it :slight_smile:

function pdf(xy)
    x = unsafe_load(xy, 1)
    y = unsafe_load(xy, 2)
    return exp(-x*x -y*y)::Cdouble
end

pdf_c = @cfunction(pdf, Cdouble, (Ptr{Cdouble}, ))