caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Markus Mottl <mottl@miss.wu-wien.ac.at>
To: francois bereux <francois.bereux@fr.thalesgroup.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] interfacing C with Ocaml (beginner questions)
Date: Thu, 7 Jun 2001 17:05:24 +0200	[thread overview]
Message-ID: <20010607170524.A29559@miss.wu-wien.ac.at> (raw)
In-Reply-To: <3B1F91D8.7AFF0264@fr.thalesgroup.com>; from francois.bereux@fr.thalesgroup.com on Thu, Jun 07, 2001 at 16:38:16 +0200

On Thu, 07 Jun 2001, francois bereux wrote:
> a) Is it possible (and if yes, how shall I do) to build a toplevel
> where my add function defined in C would be available ?

Yes, it is possible: just use the command "ocamlmktop" to link your
program, using all required files as arguments. This will produce
a toplevel.

If you find it cumbersome to remember how to link stuff for specific
targets, you can also use "OcamlMakefile", which automates all these
steps. Then you'd only have to write "make top" if you want to create
a toplevel out of your project. You can get it here:

  http://www.ai.univie.ac.at/~markus/home/ocaml_sources.html

> b) I managed to have C and Ocaml communicate using the Val_int and
> Int_val macros to convert value to the appropriate int type. But how
> should I proceed if I want that add operates on float (in Caml) i.e. on
> double in C ?
> I found a Double_val macro, but no Val_double. What is the solution ?

You have to use "copy_double" if you want to make an OCaml-float out
of a C-double. Note that this really allocates memory, it's not just a
conversion. See the chapter on interfacing to C in the manual for details:

  http://caml.inria.fr/ocaml/htmlman/manual030.html

Regards,
Markus Mottl

-- 
Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


  reply	other threads:[~2001-06-07 15:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-06-07 14:38 francois bereux
2001-06-07 15:05 ` Markus Mottl [this message]
2001-06-08 17:09 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=20010607170524.A29559@miss.wu-wien.ac.at \
    --to=mottl@miss.wu-wien.ac.at \
    --cc=caml-list@inria.fr \
    --cc=francois.bereux@fr.thalesgroup.com \
    /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).