A quite simple question on the C API and use with Julia
I want to interface Julia functions with an existing C library cLib. This library has a function(let’s call it cfunction) that creates a buffer and fills it with Cfloat. The issue is that for some (opaque) reasons, they cast the buffer into a void** before filling it.
I want to directly interface Julia code with cfunction with ccall, so I try something like that
buff = Vector{Cfloat}(undef,N);
ptr = Ref(buff): # The (void**)&buff, that does not do the trick :)
ccall((:cfunction,cLib),Cvoid,(Ptr{Cvoid},),ptr); # Calling the function
Aaaaaand it’s segfault. Any idea to address this ?
Thanks in advance
The issue if I try to use a Ptr{Ptr{Cvoid}} is that Julia try to convert it, I have to create a Base.unsafe_convert method to pass from Base.RefValue{Array{Float32,1}} to Ptr{Ptr{Nothing}}
and I don’t know how to do this. I try innocently to create a method as