Your type `Point` has in C a layout comparable to `struct*`, not `struct. You could use `immutable Point` instead, and what you're trying to achieve should work.
-erik On Thu, Feb 25, 2016 at 4:34 PM, Martin Kuzma <martin.kuzm...@gmail.com> wrote: > I have the the following type defined: > > type Point > x::Cdouble > y::Cdouble > end > Calling sizeof returns 16 as expected. But when I have for example: > > a = [Point(0.0, 0.0),Point(0.2,0.3),Point(1.1, 1.3)] > > sizeof returns 24. But I expected it to return 3 * 16 = 48. (It looks like > in the array are stored pointers to Point objects not the objects) > > My problem is that I need to convert Vector{Point} to Vector{Cdouble}. So i > tried: > > tmp1 = pointer(a) > tmp2 = convert(Ptr{Cdouble}, tmp1) > points = pointer_to_array(tmp2, length(a) * 2, true) > But the output is not what I want it to be. It is an array of some random > values. Is there a way to make this work? All i need is basically to convert > Vector{Point} to Vector{Cdouble} without the need of creating a new array. > > > > > > -- Erik Schnetter <schnet...@gmail.com> http://www.perimeterinstitute.ca/personal/eschnetter/