How to pass a void** to ccall?

I am trying to call some C code from julia. The header of the C code defines the following:

typedef void* FES;

so, I believe FES is a pointer to a Cvoid.
The same header file provides this signature for the function I want to call:

int fes_new(FES* handle,
            const fes_enum_tide_type tide,
            const fes_enum_access mode,
            const char* const path);

If I understand this correctly, the fes_new function wants a pointer to a pointer to void as its first argument.

I have tried a few different approaches to this, but I am uncertain how to create the first argument in julia in order to pass it to the function. If you have time to point me to a working example or can provide a solution to this, I would appreciate it.

I have tried variants of this:

FES = Ref(Ptr{Cvoid})

but I receive error messages like this:

ERROR: MethodError: no method matching unsafe_convert(::Type{Ptr{Ptr{Nothing}}}, ::Base.RefValue{DataType})

Basically, my question seems to be: How do I instantiate a pointer to an opaque type in order to send it into the ccall?

All the best,

You probably meant to write


Hey, thank you so much!
I had tried something similar originally,


but that didn’t work. Anyway, thx for your reply!

1 Like