From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id IAA28716 for caml-redistribution; Thu, 5 Nov 1998 08:45:46 +0100 (MET) 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 SAA17798 for ; Wed, 4 Nov 1998 18:51:49 +0100 (MET) Received: from relay5.eunet.fr (relay5.eunet.fr [193.107.193.102]) by nez-perce.inria.fr (8.8.7/8.8.7) with SMTP id SAA09772 for ; Wed, 4 Nov 1998 18:51:47 +0100 (MET) Received: from relay2.eunet.fr by relay5.eunet.fr (5.65c8d/96.05.03) via EUnet-France id AA25025; Wed, 4 Nov 1998 18:47:46 +0100 (MET) Received: from dassav (dassav.dassault-aviation.fr [193.106.72.131]) by relay2.eunet.fr (8.8.5/8.8.5) with SMTP id SAA02623; Wed, 4 Nov 1998 18:51:45 +0100 (MET) Received: from fnet-ia1.dassault-aviation.fr by dassav (5.x/SMI-SVR4) id AA07854; Wed, 4 Nov 1998 18:44:13 +0100 Received: from fnet-ia1 by fnet-ia1.dassault-aviation.fr (SMI-8.6/SMI-SVR4) id SAA29233; Wed, 4 Nov 1998 18:56:17 +0100 Sender: weis Message-Id: <36409541.37CA@dassault-aviation.fr> Date: Wed, 04 Nov 1998 18:56:17 +0100 From: Thierry Bravier Organization: Dassault Aviation DGT/DPR/DESA X-Mailer: Mozilla 3.01Gold (X11; I; SunOS 5.5.1 sun4m) Mime-Version: 1.0 To: Pascal Brisset Cc: caml-list@inria.fr Subject: Re: problem with ocamlmktop (contd) References: <3624D5BE.3060@dassault-aviation.fr> <19981015192243.14795@pauillac.inria.fr> <3627228B.20CE@dassault-aviation.fr> <36349D52.1E7B@dassault-aviation.fr> <13881.37437.266875.483207@lsun162> <13881.64982.392952.452261@whynot> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Pascal Brisset wrote: > > Here is a more complete example demonstrating: > > (1) destructors of global objects being called correctly on exit; > (2) translation of C++ exceptions to Caml exceptions; > (3) catching a C++ exception generated by a C++ primitive called > through a Caml callback. > > The only trick is that if you really need (3), you have to modify > libcamlrun.a (found in ocaml-1.07/byterun) as follows: > > Thanks for helping, I am not currently trying to map ocaml and C++ exceptions because it seems that basically, C++ exceptions don't mix well with setjmp/longjmp. so (2) and (3) are not my priorities although they are challenging. (1) is important to me ! Your example uses final ML objects successfully but I am also interested in making C++ manage its own C++ global values when entering main and most of all when leaving main (). I agree C++ global variables should be avoided and I do my very best to achieve this goal, unfortunately static variables in functions (and of course in classes too) also need to be destroyed at exit () time. This means, for most C++ compilers, compiling main () in C++ and linking with the C++ linker. The features of gcc (it can replace g++ as a linker) are not fully satisfying in my case because I mainly use egcs-1.1 (is it linkable with gcc-2.8.1 ?) and I often try to compile and link code with other C++ compilers (mainly SparcWorks and xlC). This explains why I need the -cc and -clinker options I have previously suggested. I keep the exceptions management for further explorations. Cheers -- Thierry Bravier Dassault Aviation - DGT / DPR / DESA 78, Quai Marcel Dassault F-92214 Saint-Cloud Cedex - France Telephone : (33) 01 47 11 53 07 Telecopie : (33) 01 47 11 52 83 E-Mail : mailto:thierry.bravier@dassault-aviation.fr