I want to modify the data stored in an elementary julia object (e.g. Int64) 
using external C code. I can do this if the type is wrapped in an array, but is 
it possible to do something like `pointer(x::Float64) -> address of data in x` 
with the memory being guaranteed by julia?

Here’s a short snippet to describe:
~~~

#C side
void myfunc(long* x) {
  x[0] += 1;
}

#julia side, works
x = Int64[0]
ccall((:myfunc, lib), Void, (Ptr{Void}, ), convert(Ptr{Void}, pointer(x)))
println(x)
>> [1]

#julia side, desired
x = 0
ccall((:myfunc, lib), Void, (Ptr{Void}, ), pointer(x))
println(x)
>> 1
~~~

I tried pointer_from_objref but as I understand this gives me the pointer of 
the whole julia type with meta-data etc. If I write to this address in C, I 
fear I’ll have problems.

Reply via email to