On 21 June 2015 at 17:41, Isaiah Norton <[email protected]> wrote:
> I would expect gibbrrish at first because the memory is uninitialized.
> What version of Julia? Passing structs by value doesn't work on 0.3.
>
I have 0.3.8 -- How should I pass a struct then? Btw, I can confirm that
passing struct by value doesn't work. If I write:
void particles_add(struct particle pt){
while (Nmax <= N){
Nmax += 128;
particles = realloc(particles,sizeof(struct particle)*Nmax);
}
particles[N] = pt;
printf("pt.x, pt.y, pt.z = %f, %f, %f\n", pt.x, pt.y, pt.z);
N++;
}
in Julia I get:
julia> add(x=1,y=2,z=3)
pt.x, pt.y, pt.z = 0.000000, 0.000000, 0.000000
So what should I pass instead? Or should I switch to Julia 0.4? How stable
is 0.4?
> Also note that you will need to reload the particles ptr any time you read
> from it because realloc can invalidate the pointer.
>
Good to keep in mind. Thanks.
Cheers,
Daniel.