<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2003/01/ebd86b28c2ef28b50a46fde80caaf934"
  from="Daniel Andor &lt;da209@c...&gt;"
  author="Daniel Andor"
  date="2003-01-11T19:08:35"
  subject="[Caml-list] C -&gt; CAML linking: loosing values in arrays??"
  prev="2003/01/b3381ea52ca855463acfe1b560847b5a"
  next="2003/01/a3f8af61dda21ed4c9413a149d64bf07"
  next-in-thread="2003/01/a3f8af61dda21ed4c9413a149d64bf07"
  prev-thread="2003/01/b3381ea52ca855463acfe1b560847b5a"
  next-thread="2003/01/ae290911e3ac98ba444f0ad41ede595f"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] C -&gt; CAML linking: loosing values in arrays??">
<msg 
  url="2003/01/ebd86b28c2ef28b50a46fde80caaf934"
  from="Daniel Andor &lt;da209@c...&gt;"
  author="Daniel Andor"
  date="2003-01-11T19:08:35"
  subject="[Caml-list] C -&gt; CAML linking: loosing values in arrays??">
<msg 
  url="2003/01/a3f8af61dda21ed4c9413a149d64bf07"
  from="Artem Prisyznuk &lt;tema@s...&gt;"
  author="Artem Prisyznuk"
  date="2003-01-12T00:15:49"
  subject="Re: [Caml-list] C -&gt; CAML linking: loosing values in arrays??">
<msg 
  url="2003/01/bcec04263a1c7a487d0b250728b97452"
  from="Daniel Andor &lt;da209@c...&gt;"
  author="Daniel Andor"
  date="2003-01-12T01:03:19"
  subject="Re: [Caml-list] C -&gt; CAML linking: loosing values in arrays??">
</msg>
</msg>
<msg 
  url="2003/01/3805be8a550d5c992f50ef38d54d300a"
  from="Damien Doligez &lt;damien.doligez@i...&gt;"
  author="Damien Doligez"
  date="2003-01-15T15:09:23"
  subject="Re: [Caml-list] C -&gt; CAML linking: loosing values in arrays??">
</msg>
</msg>
</thread>

<contents>
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&lt;NUM_DIMS; i++)
    p[i] = &amp;(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

</contents>

</message>

