caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@kurims.kyoto-u.ac.jp>
To: mavila@irisa.fr
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] ocaml_startup et Solaris/x86
Date: Wed, 05 Nov 2003 11:18:31 +0900	[thread overview]
Message-ID: <20031105111831A.garrigue@kurims.kyoto-u.ac.jp> (raw)
In-Reply-To: <3FA7AF07.1080207@IRISA.fr>

From: Mathieu Avila <mavila@irisa.fr>

> >I'm using ocaml on Solaris8/x86, and many C libraries, with no
> >problem.
> >
> Are you able to call the ocaml code from the C ? I think this is rather 
> different from calling C libs from a standalone OCaml code.

If you mean calling callback, I can. My libraries are full of
callbacks from C to caml.

> In my case, i mix the 2 langages in this way :
> 
> cmain.ml:
> --------------------------------------------------------
> let cmain_ocaml n = try
> ...
> ;;
> 
> let _ = Callback.register "cmain_ocaml" cmain_ocaml
> --------------------------------------------------------
> 
> in a cmain_cpp.cpp , where there is the "real" main() function:
> --------------------------------------------------------
>  static value * cmain_closure = NULL;
>  if (cmain_closure==NULL)
>    cmain_closure = caml_named_value("cmain_ocaml");
>  result = Int_val(callback(*cmain_closure,Val_int(n)));
> --------------------------------------------------------
> 
> It crashses when calling :  callback(*cmain_closure...)
> 
> All is compiled into native solaris object code.
> The same thing works perfectly on solaris/sparc.

Do I understand correctly than the C code above is inside the main
function?
Then I cannot see how it would work. Callback.register dynamically
adds "cmain_ocaml" to a table of known functions. If you don't call
ocaml's main function (i.e. the main() function of the ocaml C
runtime, or at least caml_main()), your caml function will not be
registered and this should not work.

Jacques Garrigue

-------------------
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:[~2003-11-05  2:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-03  7:56 Mathieu Avila
2003-11-04  1:09 ` Jacques Garrigue
2003-11-04 13:52   ` Mathieu Avila
2003-11-05  2:18     ` Jacques Garrigue [this message]
2003-11-05  8:29       ` Mathieu Avila

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=20031105111831A.garrigue@kurims.kyoto-u.ac.jp \
    --to=garrigue@kurims.kyoto-u.ac.jp \
    --cc=caml-list@inria.fr \
    --cc=mavila@irisa.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).