Ccall: how to wrap call-by-reference C functions?

The one you declare you’re passing to the C function, Ref{Cint}. Note that Cint is an alias for Int32, but integer literals on a 64-bit Julia are Int64

julia> a = Ref{Cint}(13)
Base.RefValue{Int32}(13)

julia> ccall((:put_7, "./libptrtest.so"), Cvoid, (Ref{Cint},), a)

julia> a
Base.RefValue{Int32}(7)

julia> a[]
7

For reference, see the relevant section of the manual: Passing Pointers for Modifying Inputs

2 Likes