From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id DAA14294; Wed, 5 Nov 2003 03:18:41 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id DAA14298 for ; Wed, 5 Nov 2003 03:18:39 +0100 (MET) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id hA52Ib105941 for ; Wed, 5 Nov 2003 03:18:37 +0100 (MET) Received: from localhost (suiren.kurims.kyoto-u.ac.jp [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.9.3p2-20030924/3.7W) with ESMTP id LAA13338; Wed, 5 Nov 2003 11:18:31 +0900 (JST) To: mavila@irisa.fr Cc: caml-list@inria.fr Subject: Re: [Caml-list] ocaml_startup et Solaris/x86 In-Reply-To: <3FA7AF07.1080207@IRISA.fr> References: <3FA60A42.3040707@IRISA.fr> <20031104100910W.garrigue@kurims.kyoto-u.ac.jp> <3FA7AF07.1080207@IRISA.fr> X-Mailer: Mew version 1.94.2 on Emacs 21.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20031105111831A.garrigue@kurims.kyoto-u.ac.jp> Date: Wed, 05 Nov 2003 11:18:31 +0900 From: Jacques Garrigue X-Dispatcher: imput version 20000228(IM140) X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 jacques:01 mathieu:01 libs:01 callback:01 callbacks:01 langages:01 callback:01 val:01 val:01 dynamically:01 ocaml's:01 runtime:01 jacques:01 ocaml:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk From: Mathieu Avila > >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