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 RAA18134; Thu, 26 Jun 2003 17:14:55 +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 RAA18328 for ; Thu, 26 Jun 2003 17:14:54 +0200 (MET DST) Received: from mail.eecs.harvard.edu (bowser.eecs.harvard.edu [140.247.60.24]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h5QFErf08616 for ; Thu, 26 Jun 2003 17:14:53 +0200 (MET DST) Received: by mail.eecs.harvard.edu (Postfix, from userid 32018) id AD06754C495; Thu, 26 Jun 2003 11:14:50 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.eecs.harvard.edu (Postfix) with ESMTP id AAAFF54C48A; Thu, 26 Jun 2003 11:14:50 -0400 (EDT) Date: Thu, 26 Jun 2003 11:14:50 -0400 (EDT) From: Lex Stein To: Jung Woon Ho Cc: caml-list@inria.fr Subject: Re: [Caml-list] interfacing C and OCaml In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam: no; 0.00; stein:01 caml-list:01 interfacing:01 camlparam:01 camllocal:01 alloc:01 callback:01 camlreturn:01 jung:99 bug:01 faq:01 beginner's:01 beginners:01 bin:01 caml-bugs:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi, In the C code allocate a memory block value of size 5 with tag 0. CAMLparam0 (); CAMLlocal2 (v, v1); static value * clos; v = alloc_tuple (5); /* assign to the fields using the Store_Field macro */ clos = caml_named_value ("c_function_name") /* where c_function_name is registered from within the Caml code via (Callback.register "c_function_name" function_name) Then just call the Caml routine via callback like so: */ v1 = callback (*clos, v); Remember to return from the C function with one of the CAMLreturn macros to be friendly with the garbage collector. Let me know if you have any further questions/problems with Caml/C interaction. I'm happy to help. Lex -- Lex Stein http://www.eecs.harvard.edu/~stein/ stein@eecs.harvard.edu TEL: 617-233-0246 On Thu, 26 Jun 2003, Jung Woon Ho wrote: > Hi, > > Can anybody explain me if there is anyway that I can pass in > a (int*int*int*int*int) from a C function to OCaml. > > Thank you. > > _________________________________________________________________ > The new MSN 8: smart spam protection and 2 months FREE* > http://join.msn.com/?page=features/junkmail > > ------------------- > 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 > ------------------- 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