Browse thread
[Caml-list] C -> CAML linking: loosing values in arrays??
-
Daniel Andor
- Artem Prisyznuk
- Damien Doligez
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2003-01-15 (15:09) |
From: | Damien Doligez <damien.doligez@i...> |
Subject: | Re: [Caml-list] C -> CAML linking: loosing values in arrays?? |
On Saturday, January 11, 2003, at 08:07 PM, Daniel Andor wrote: > parameters. Since it's for numerics, I want to pass arrays of doubles. > return alloc_array(make_float,p); You cannot use alloc_array to return a value of type [float array]. This is because arrays of floating-point numbers are not represented like the other array types in O'Caml: they are allocated in-line, without the usual pointer indirection. You will have to allocate the array with [alloc], then fill in the elements with [Store_double_field]: #define NUM_DIMS 4 value make_float_array(double *ds) { int i; value res; res = alloc (NUM_DIMS*Double_wosize, Double_array_tag); for (i=0; i<NUM_DIMS; i++){ Store_double_field (res, i, ds[i]); } return res; } -- Damien ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners