I have function baz which outputs the product of the input at 2:
function baz{T}(x::T)
return convert(Cdouble,x*2)::Cdouble
end
I want to use this function in some C function that I am calling. Running
julia> myptr=cfunction(baz,Cdouble,(Ref{Cdouble}))
Ptr{Void} @0x00007f2623c9c1d0
is fine, and I can proceed to pass the function pointer to my C function.
Say I want the product of the input and another integer. I have a higher
order function bar
function bar(y)
function foo{T}(x::T)
return convert(Cdouble,x*y)::Cdouble
end
end
now I can get the baz function like this
julia> foo=bar(2)
foo (generic function with 1 method)
foo has the same method as baz, and the same functionality, but cfunction
results in an error:
julia> myptr=cfunction(foo,Cdouble,(Ref{Cdouble}))
ERROR: cfunction: no method exactly matched the required type signature
(function not yet c-callable)
in cfunction at c.jl:9
:(
How can I pass the function pointers of the outputs of my higher order
function bar to my C function?