caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] C -> CAML linking: loosing values in arrays??
@ 2003-01-11 19:07 Daniel Andor
  2003-01-11 23:20 ` Artem Prisyznuk
  2003-01-15 15:10 ` Damien Doligez
  0 siblings, 2 replies; 4+ messages in thread
From: Daniel Andor @ 2003-01-11 19:07 UTC (permalink / raw)
  To: Caml List

Hi All,

I'm trying to call a numerical routine I wrote in caml from c.  I'm using the 
-output-obj option of ocamlopt, and have stub functions in c that convert the 
parameters.  Since it's for numerics, I want to pass arrays of doubles.  So I 
use make_float_array from below to convert a 4dimensional doube array into a 
value ready to be passed to caml.

value make_float(double *d) 
{ 
  /* value of d intentionally ignored while we debug... */
  return copy_double(0.0);
}

#define NUM_DIMS 4
value make_float_array(double *ds)
{
  int i;
  double* p[NUM_DIMS+1];
  p[NUM_DIMS]=NULL;
  for (i=0; i<NUM_DIMS; i++)
    p[i] = &(ds[i]);
  return alloc_array(make_float,p);
}

The caml code gets called correctly, and from within it I can see that the 
length or the arrays and the content are bogus (they come out length 2, not 
4, with the first elements looking like this: 62.6141, not 0.0).

If I pass a non-array double using copy_double(), it works and I get the 
correct number on the other side.

Any ideas as to where I've gone wrong?

Thanks,
Daniel.
-------------------
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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-01-15 15:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-11 19:07 [Caml-list] C -> CAML linking: loosing values in arrays?? Daniel Andor
2003-01-11 23:20 ` Artem Prisyznuk
2003-01-12  1:02   ` Daniel Andor
2003-01-15 15:10 ` Damien Doligez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).