caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Yoann Padioleau <padator@wanadoo.fr>
To: Yoann Padioleau <padator@wanadoo.fr>
Cc: caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] how to call an OCaml library from C/C++ ?
Date: Tue, 24 Aug 2010 11:22:05 -0700	[thread overview]
Message-ID: <0EF0E664-A49F-4284-9163-61AA6C48C401@wanadoo.fr> (raw)
In-Reply-To: <1FEF5EC1-5F99-4400-A787-63A8352DDF85@wanadoo.fr>


On Aug 24, 2010, at 10:50 AM, Yoann Padioleau wrote:

> 
> 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;
> }

Also it is possible to have multiple independent ocaml runtime at the same time 
so such a function is thread-safe ?


> 
> and then link my c++ program with my_extension.o  and some .a containing ocaml code.
> 
> 
> 
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
> 




      reply	other threads:[~2010-08-24 18:22 UTC|newest]

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

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=0EF0E664-A49F-4284-9163-61AA6C48C401@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).