Re: problem with ocamlmktop (contd)

From: Thierry Bravier (
Date: Wed Nov 04 1998 - 18:56:17 MET

Message-Id: <>
Date: Wed, 04 Nov 1998 18:56:17 +0100
From: Thierry Bravier <>
To: Pascal Brisset <>
Subject: Re: problem with ocamlmktop (contd)

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.


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 :           

This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:16 MET