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: 2003-06-27 (05:24)
From: Mikhail Fedotov <mikhail@k...>
Subject: Re[2]: [Caml-list] interfacing C and OCaml

JBR> 1. Should I use
JBR> CAMLprim value input(value channel, value buffer, value offset, value
JBR> length)
JBR> {
JBR>   return ...
JBR> }

Yes. This function can be called from other C function or from OCaml.

JBR> as in 18.1.2 in the manual, or

JBR> void foo (value v1, value v2, value v3)
JBR> {
JBR> CAMLparam3 (v1, v2, v3);
JBR> ...
JBR> CAMLreturn0;
JBR> }

This if for functions called from C only. Not suitable for use from
OCaml directly.

Should be specified in the manual, I believe, but I've got no response
in the list to my comment on this. I hope it will be in the manual for
the OCaml 3.07.

JBR> ------------------------------------------------
JBR> 3. Is it correct to store p in the custom block v by
JBR> CAMLlocal(v);
JBR> v = alloc_custom(ops, 4, 0, 1);
JBR> (my_type *) Data_custom_val(v) = p;
JBR> ?
JBR> When does the parameter "size" (here "4") vary ?

my_type *t;
my_type r;

v = alloc_custom(ops, 1 + sizeof(my_type), 1, 10);
t = (my_type *) Data_custom_val(v);

t->some_int_member = 7;


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