caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] C <-> OCaml questions
@ 2002-06-17  9:35 Jérôme Marant
  2002-06-17 15:42 ` Dmitry Bely
  0 siblings, 1 reply; 3+ messages in thread
From: Jérôme Marant @ 2002-06-17  9:35 UTC (permalink / raw)
  To: caml-list

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-06-17 19:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-17  9:35 [Caml-list] C <-> OCaml questions Jérôme Marant
2002-06-17 15:42 ` Dmitry Bely
2002-06-17 17:43   ` Jérôme Marant

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).