[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Jérôme_Marant <jerome.marant@f...> |
| Subject: | [Caml-list] C <-> OCaml questions |
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,
--
Jérôme 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