I am coupling to a C library and would like to pass null pointers to a function. However, I want to pass a null pointer of type Ptr{<mytype>}
. When I do that I end up with a convert error, because C_NULL
of Ptr{Void}
. It would be most straightforward if I could just use C_NULL
everywhere.
Is there a way to write a custom convert function? I tried
convert(::Type{Ptr{<mytype>}}, C_NULL) = Ref{<mytype>}(0)
but that didn’t seem to do anything.