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 BAA15066; Sat, 28 Aug 2004 01:15:42 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id BAA16653 for ; Sat, 28 Aug 2004 01:15:41 +0200 (MET DST) Received: from herd.plethora.net (herd.plethora.net [205.166.146.1]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id i7RNFd73003193 for ; Sat, 28 Aug 2004 01:15:39 +0200 Received: from bhurt.plethora.net (bhurt.plethora.net [205.166.146.49]) by herd.plethora.net (8.11.6/8.10.1) with ESMTP id i7RNFTB16307; Fri, 27 Aug 2004 18:15:33 -0500 (CDT) Date: Fri, 27 Aug 2004 18:24:14 -0500 (CDT) From: Brian Hurt X-X-Sender: bhurt@localhost.localdomain To: David McClain cc: caml-list@inria.fr Subject: Re: [Caml-list] C++ Throws In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Miltered: at nez-perce with ID 412FC09B.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 mcclain:01 unhandled:01 abort:01 extern:01 foo:01 foo:01 mangling:01 extern:01 generic:01 ocaml:01 ocaml:01 handler:01 handler:01 interfaces:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Fri, 27 Aug 2004, David McClain wrote: > I now see that OCaml is not converting anything, per se... Apparently > when the throw handler detects an unhandled condition it decides to > call abort(), against which there is no defense. I don't know what precisely is going on here, but Ocaml interfaces to C, which doesn't know anything about exceptions. You might try something like (sorry, I'm no C++ guru): extern "C" value foo(value c); value foo(value C) { /* normal Ocaml wrapper code for C */ try { /* exception throwing code for C++. */ } with (Exception e) { /* Translate the C++ exception to an Ocaml exception */ } } The big difference between a C++ function and C function is the name mangling. I doubt Ocaml could find a C++ function for linking after it was name mangled. So the extern "C" tells C++ to not namemangle the function name. There is no way I know of to determine what exceptions a function call might throw. > So there appears to be something relatively complex going on across the > foreign function interface with OCaml and C. This override is what > frustrates the attempts to create a generic C++ exception handler. I think you also have a C/C++ interface problem (and yes, Virginia, they do exist). -- "Usenet is like a herd of performing elephants with diarrhea -- massive, difficult to redirect, awe-inspiring, entertaining, and a source of mind-boggling amounts of excrement when you least expect it." - Gene Spafford Brian ------------------- 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