# How to pass a void\*\* to ccall?

**URL:** https://discourse.julialang.org/t/how-to-pass-a-void-to-ccall/77655
**Category:** New to Julia
**Created:** [March 9, 2022, 11:14pm UTC](https://discourse.julialang.org/t/how-to-pass-a-void-to-ccall/77655 "2022-03-09T23:14:16Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ezaron](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ezaron/32/18778_2.png) [@ezaron](https://discourse.julialang.org/u/ezaron)
#### Post date: [March 9, 2022, 11:14pm UTC](https://discourse.julialang.org/t/how-to-pass-a-void-to-ccall/77655/1 "2022-03-09T23:14:16Z")

</div>

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

```julia
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:

```julia
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:

```julia
FES = Ref(Ptr{Cvoid})
ierr=ccall((:fes_new,"libfes.so"),Cint,
           (Ptr{Ptr{Cvoid}},Cint,Cint,Cstring),
           FES,FES_TIDE,FES_IO,INI_U)

```

but I receive error messages like this:

```julia
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,  
Ed

---

<div class="post-metadata">

### Author: ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)
#### Post date: [March 9, 2022, 11:33pm UTC](https://discourse.julialang.org/t/how-to-pass-a-void-to-ccall/77655/2 "2022-03-09T23:33:41Z")

</div>

> [@ezaron](#):
>
> `FES = Ref(Ptr{Cvoid})`

You probably meant to write

```julia
Ref{Ptr{Cvoid}}()

```

---

<div class="post-metadata">

### Author: ![ezaron](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ezaron/32/18778_2.png) [@ezaron](https://discourse.julialang.org/u/ezaron)
#### Post date: [March 9, 2022, 11:38pm UTC](https://discourse.julialang.org/t/how-to-pass-a-void-to-ccall/77655/3 "2022-03-09T23:38:23Z")

</div>

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

```julia
Ref{Ptr{Cvoid}}(nothing),

```

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