caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Jérôme Marant" <jerome.marant@fr.thalesgroup.com>
To: caml-list@inria.fr
Subject: [Caml-list] C <-> OCaml questions
Date: Mon, 17 Jun 2002 11:35:14 +0200	[thread overview]
Message-ID: <20020617113514.A30103@fr.thalesgroup.com> (raw)

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


             reply	other threads:[~2002-06-17  9:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-17  9:35 Jérôme Marant [this message]
2002-06-17 15:42 ` Dmitry Bely
2002-06-17 17:43   ` Jérôme Marant

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=20020617113514.A30103@fr.thalesgroup.com \
    --to=jerome.marant@fr.thalesgroup.com \
    --cc=caml-list@inria.fr \
    /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;
as well as URLs for NNTP newsgroup(s).