caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Yoann Padioleau <padator@wanadoo.fr>
To: caml users <caml-list@inria.fr>
Subject: how to call an OCaml library from C/C++ ?
Date: Tue, 24 Aug 2010 10:50:36 -0700	[thread overview]
Message-ID: <1FEF5EC1-5F99-4400-A787-63A8352DDF85@wanadoo.fr> (raw)

Hi,

Is there a way to call OCaml library from a C/C++ program without the C++ program
knowing it's OCaml code ? I mean I can not touch the main of the C++ program
so it has to be completely transparent and it would be good if each call to the ocaml library
once finished free all the memory it was using.
Can we call  caml_startup() multiple times ? is there a caml_cleanup ?

Ideally I would like from C/C++ to have:


my_extension.c:
char* sanitize_stuff(char *s) {

  caml_startup();
  char * res = <call_ocaml_code_with_s>;
  caml_cleanup();
  return res;
}

and then link my c++ program with my_extension.o  and some .a containing ocaml code.




             reply	other threads:[~2010-08-24 17:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-24 17:50 Yoann Padioleau [this message]
2010-08-24 18:22 ` [Caml-list] " Yoann Padioleau

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=1FEF5EC1-5F99-4400-A787-63A8352DDF85@wanadoo.fr \
    --to=padator@wanadoo.fr \
    --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).