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 LAA25741; Mon, 17 Jun 2002 11:35:21 +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 LAA25500 for ; Mon, 17 Jun 2002 11:35:20 +0200 (MET DST) Received: from gwsmtp.thomson-csf.com (gwsmtp.thomson-csf.com [195.101.39.226]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g5H9ZJ119336 for ; Mon, 17 Jun 2002 11:35:19 +0200 (MET DST) Received: from thomplex.thomson-csf.com (200.3.2.2) by gwsmtp.thomson-csf.com (NPlex 5.1.053) id 3D0D72040000C8D0 for caml-list@inria.fr; Mon, 17 Jun 2002 11:39:26 +0200 Received: from THALESCAN.CORP.THALES (200.3.1.29) by thomplex.thomson-csf.com (NPlex 5.1.036) id 3D0D70BA0000DB54 for caml-list@inria.fr; Mon, 17 Jun 2002 11:34:40 +0200 Received: from bgxplex3.bgx.airsys.thomson-csf.com (1.38.9.153) by bgxplex.bgx.airsys.thomson-csf.com (NPlex 5.1.053) id 3CF1E4D100043F9C for caml-list@inria.fr; Mon, 17 Jun 2002 11:35:18 +0200 Received: from bgxplex3.bgx.airsys.thomson-csf.com (1.38.9.153) by bgxplex3.bgx.airsys.thomson-csf.com (NPlex 5.1.053) id 3CE3A3A1000379AC for caml-list@inria.fr; Mon, 17 Jun 2002 11:37:03 +0200 Received: from 187.150.3.12 by bgxplex3.bgx.airsys.thomson-csf.com (InterScan E-Mail VirusWall NT); Mon, 17 Jun 2002 11:37:00 +0200 Received: from af_mara by lully.bgx.airsys.thomson-csf.com with local (Exim 3.22 #1 (Red Hat Linux)) id 17Jsuo-0007pj-00 for ; Mon, 17 Jun 2002 11:35:14 +0200 Date: Mon, 17 Jun 2002 11:35:14 +0200 From: =?iso-8859-1?Q?J=E9r=F4me_Marant?= To: caml-list@inria.fr Subject: [Caml-list] C <-> OCaml questions Message-ID: <20020617113514.A30103@fr.thalesgroup.com> Mail-Followup-To: caml-list@inria.fr Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline User-Agent: Mutt/1.2.5i Content-Transfer-Encoding: Quoted-Printable Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hello, I'm currently writing OCaml bindings for some C libraries and I would like to get some details about how to convert C pointers to OCaml types. 1/ Let's assume we have the following C function: Bar * Foo(char *S); In OCaml, I would like to convert the (Bar *) type to type bar Question: how do I perform the conversion? Should I allocate a bloc of size sizeof(Bar *), assign the pointer value to it and return it to OCaml? How can I make it portable, i.e. independant on the size of pointers ? (32 or 64 bits). 2/ Let's assume we have the same C function: Bar * Foo(char *S); The OCaml matching function should be: val foo: string -> bar Now assume that NULL is a significant value for S. How can I tell OCaml to pass NULL to the C function? Should I create a specific version of foo with no argument but which passed NULL in the C interface? Thanks in advance. Regards,=20 --=20 J=E9r=F4me Marant ------------------- 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