Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] interfacing C and OCaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Lex Stein <stein@e...>
Subject: Re: [Caml-list] interfacing C and OCaml

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 Stein                   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*
> -------------------
> To unsubscribe, mail Archives:
> Bug reports: FAQ:
> Beginner's list:

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: