On Sun, Jul 10, 2016 at 5:29 PM, Jeffrey Sarnoff
<[email protected]> wrote:
> According to the v0.5 docs,  `ccall(..., (Ptr{BigFloat},..), &aBigFloat,
> ..)` is deprecated in favor of `ccall(..., (Ref{BigFloat},..), aBigFloat,
> ..)`.
> It seems that using `Ptr{Type}` needs to be paired with `&varOfType` using
> the ampersand. When would one use `Ptr{Type}`?
>

In general, replacing `Ptr{T}` with `Ref{T}` in the ccall argument
signature should work. (This doesn't include custom conversions of
course).

The comparison between `Ref` and `&` only applies when passing an
julia object as reference to C code. In such case, the preferred way
is to use `Ref`. However, for bitstype (`isbits` type), `Ref` will
cause a heap allocation while `Ptr`+`&` won't, which is why the
`Ptr`+`&` is not officially deprecated yet (i.e. there's no depwarn
for it).

>

Reply via email to