Yes. The second version is garbage. (i.e. the value you get in C is not usable.)
It’s talking about the argument type in the ccall
, i.e. where you have Ptr{Cvoid}
and it mosly apply to when you know the type you’ll use so that you can write ccall(.... (Ref{Int}, ...), 1)
.
Almost never. In the context of ccall
the function is there to implement unsafe_convert
. Using it would be equivalent to using unsafe_convert
. If you don’t have a case where you need unsafe_convert
, don’t use pointer_from_objref
.