From: Daniel Andor <da209@cam.ac.uk>
To: Caml List <caml-list@inria.fr>
Subject: [Caml-list] C -> CAML linking: loosing values in arrays??
Date: Sat, 11 Jan 2003 19:07:51 +0000 [thread overview]
Message-ID: <200301111907.51989.da209@cam.ac.uk> (raw)
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
next reply other threads:[~2003-01-11 19:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-11 19:07 Daniel Andor [this message]
2003-01-11 23:20 ` Artem Prisyznuk
2003-01-12 1:02 ` Daniel Andor
2003-01-15 15:10 ` Damien Doligez
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200301111907.51989.da209@cam.ac.uk \
--to=da209@cam.ac.uk \
--cc=Daniel.Andor@physics.org \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).