From: Lex Stein <stein@eecs.harvard.edu>
To: Jung Woon Ho <unosoft@hotmail.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] interfacing C and OCaml
Date: Thu, 26 Jun 2003 11:14:50 -0400 (EDT) [thread overview]
Message-ID: <Pine.BSF.4.51.0306261106050.35616@bowser.eecs.harvard.edu> (raw)
In-Reply-To: <BAY1-F53carcR4ZDgC80002a268@hotmail.com>
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
next prev parent reply other threads:[~2003-06-26 15:14 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-06-26 14:42 Jung Woon Ho
2003-06-26 15:14 ` Lex Stein [this message]
2003-06-26 19:02 ` Jean-Baptiste Rouquier
2003-06-27 5:24 ` Re[2]: " Mikhail Fedotov
2003-06-27 8:31 ` Jean-Baptiste Rouquier
2003-06-27 8:59 ` Re[2]: " Mikhail Fedotov
2003-06-27 12:57 ` art yerkes
2003-06-27 13:14 ` Re[4]: " Mikhail Fedotov
2003-06-27 17:45 ` art yerkes
-- strict thread matches above, loose matches on Subject: below --
2003-06-19 19:58 [Caml-list] Interfacing C and Ocaml Jung Woon Ho
2003-06-19 20:06 ` Kip Macy
2003-06-19 20:28 ` art yerkes
2001-03-30 8:54 [Caml-list] Interfacing C++ " David Chemouil
2001-03-30 9:13 ` Bruce Hoult
2001-03-30 9:24 ` Fergus Henderson
2001-03-28 8:37 David Chemouil
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=Pine.BSF.4.51.0306261106050.35616@bowser.eecs.harvard.edu \
--to=stein@eecs.harvard.edu \
--cc=caml-list@inria.fr \
--cc=unosoft@hotmail.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