Ccall with pointer argument to array of custom type via an NTuple of immutables

This is wrong, you at least need Ref{MyType}()

Cstring

Never call pointer_from_objref period.

Use ccall(..., (..., Ptr{Void}, Ref{MyType}, ...), ..., Ref(wrapped_args), rarg, ...) instead.

Ref(MyType())

You don’t.

You shouldn’t define it for NTuple

To make the syntax more consistent we could define in base

Base.cconvert{N,T}(::Type{Ref{T}}, t::NTuple{N,T}) = Ref{NTuple{N,T}}(t)
Base.unsafe_convert{N,T}(::Type{Ref{T}}, r::Ref{NTuple{N,T}}) = unsafe_convert(Ref{NTuple{N,T}}, r)
1 Like