<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2003/11/1cd61c5f67a7aa90f725b489dbc1143b"
  from="Jacques Garrigue &lt;garrigue@k...&gt;"
  author="Jacques Garrigue"
  date="2003-11-05T02:18:41"
  subject="Re: [Caml-list] ocaml_startup et Solaris/x86"
  prev="2003/11/fcf4916c9d449dfdc24dc7760ef38db4"
  next="2003/11/7d1a89526a373d9c8ad55df4f4d4ad97"
  prev-in-thread="2003/11/fc711ff363ee98e5a52de94c646ee486"
  next-in-thread="2003/11/92b94daa2fb95ae6a57491d9c74ea2ef"
  prev-thread="2003/11/5ebcd6d0eea2cdbc8d8713f184910c24"
  next-thread="2003/11/96c5a045d70b126cf9ebbe6b346fc3dd"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] ocaml_startup et Solaris/x86">
<msg 
  url="2003/11/927fa5865c499289949ce45512930e10"
  from="Mathieu Avila &lt;mavila@i...&gt;"
  author="Mathieu Avila"
  date="2003-11-03T07:56:52"
  subject="[Caml-list] ocaml_startup et Solaris/x86">
<msg 
  url="2003/11/9caf042d7c5391a959764eb56c3450e0"
  from="Jacques Garrigue &lt;garrigue@k...&gt;"
  author="Jacques Garrigue"
  date="2003-11-04T01:09:10"
  subject="Re: [Caml-list] ocaml_startup et Solaris/x86">
<msg 
  url="2003/11/fc711ff363ee98e5a52de94c646ee486"
  from="Mathieu Avila &lt;mavila@i...&gt;"
  author="Mathieu Avila"
  date="2003-11-04T13:52:10"
  subject="Re: [Caml-list] ocaml_startup et Solaris/x86">
<msg 
  url="2003/11/1cd61c5f67a7aa90f725b489dbc1143b"
  from="Jacques Garrigue &lt;garrigue@k...&gt;"
  author="Jacques Garrigue"
  date="2003-11-05T02:18:41"
  subject="Re: [Caml-list] ocaml_startup et Solaris/x86">
<msg 
  url="2003/11/92b94daa2fb95ae6a57491d9c74ea2ef"
  from="Mathieu Avila &lt;mavila@i...&gt;"
  author="Mathieu Avila"
  date="2003-11-05T08:30:00"
  subject="Re: [Caml-list] ocaml_startup et Solaris/x86">
</msg>
</msg>
</msg>
</msg>
</msg>
</thread>

<contents>
From: Mathieu Avila &lt;mavila@irisa.fr&gt;

&gt; &gt;I'm using ocaml on Solaris8/x86, and many C libraries, with no
&gt; &gt;problem.
&gt; &gt;
&gt; Are you able to call the ocaml code from the C ? I think this is rather 
&gt; 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.

&gt; In my case, i mix the 2 langages in this way :
&gt; 
&gt; cmain.ml:
&gt; --------------------------------------------------------
&gt; let cmain_ocaml n = try
&gt; ...
&gt; ;;
&gt; 
&gt; let _ = Callback.register "cmain_ocaml" cmain_ocaml
&gt; --------------------------------------------------------
&gt; 
&gt; in a cmain_cpp.cpp , where there is the "real" main() function:
&gt; --------------------------------------------------------
&gt;  static value * cmain_closure = NULL;
&gt;  if (cmain_closure==NULL)
&gt;    cmain_closure = caml_named_value("cmain_ocaml");
&gt;  result = Int_val(callback(*cmain_closure,Val_int(n)));
&gt; --------------------------------------------------------
&gt; 
&gt; It crashses when calling :  callback(*cmain_closure...)
&gt; 
&gt; All is compiled into native solaris object code.
&gt; 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

</contents>

</message>

