3 ms·
For an array, you'd have to worry about row- vs column-major orientation if multidimensional, but for simple numeric vectors and base strings (which are just a
by cbkeller 4y ago
For an array, you'd have to worry about row- vs column-major orientation if multidimensional, but for simple numeric vectors and base strings (which are just a collection of UInt8s in memory), it appears to be sufficient to merely pass the pointer to C:
julia> a = "hello there!"
"hello there!"
julia> p = pointer(a)
Ptr{UInt8} @0x000000010a431458
julia> ccall(:puts, Int, (Ptr{UInt8},), p)
hello there!
10
For vectors of structs, then of course you'd need to know the layout of each struct when operating on them from the other language, but still doable enough in principle. Vectors of union types would be trickier though.