From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA32301; Thu, 7 Jun 2001 17:05:42 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id RAA32442 for ; Thu, 7 Jun 2001 17:05:41 +0200 (MET DST) Received: from miss.wu-wien.ac.at (miss.wu-wien.ac.at [137.208.107.17]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f57F5e925478 for ; Thu, 7 Jun 2001 17:05:41 +0200 (MET DST) Received: (from mottl@localhost) by miss.wu-wien.ac.at (8.9.0/8.9.0) id RAA08103; Thu, 7 Jun 2001 17:05:25 +0200 (MET DST) Date: Thu, 7 Jun 2001 17:05:24 +0200 From: Markus Mottl To: francois bereux Cc: caml-list@inria.fr Subject: Re: [Caml-list] interfacing C with Ocaml (beginner questions) Message-ID: <20010607170524.A29559@miss.wu-wien.ac.at> References: <3B1F91D8.7AFF0264@fr.thalesgroup.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <3B1F91D8.7AFF0264@fr.thalesgroup.com>; from francois.bereux@fr.thalesgroup.com on Thu, Jun 07, 2001 at 16:38:16 +0200 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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