comp.lang.ada
 help / color / mirror / Atom feed
From: Laurent Guerby <guerby@gnat.com>
Subject: Re: HELP! C++ exceptions SunOS
Date: 1997/12/19
Date: 1997-12-19T00:00:00+00:00	[thread overview]
Message-ID: <199712191141.MAA16696@oslo.act-europe.fr> (raw)
In-Reply-To: 349989C3.35F6@ibm.net


> NOW, I have a main program calling func1(). When the main is in C++,
> everything is ok, func1 catches the exception and prints the message.
> However, when the main is in ada, the libC.a prints an error and aborts
> the program, saying something about no exception handler.
> 
> My guess is that there is some code running in the C++ version BEFORE
> the main(), perhaps something that comes from crt?.o that the linker
> puts in automatically, but what? and how does it work? and most
> important - how do a simulate it for a program who's main is in ada?

   You can't because (I think, glad to be wrong here) there is nothing
   in the C++ standard like 'adainit' and 'adafinal' for Ada 95 (the
   Ada 95 designers thought about foreign languages). If you have C++
   around, the main must be in C++ so that the C++ run-time is
   initialized, as you guessed.

   I've done the kind of thing you describe using GNAT and Sun C++
   compiler, as long as C++ catches its own exceptions, it works fine.

   Just write a dummy main in C++ that calls adainit, the main Ada
   procedure (put an pragma Export (C, ...) on it in the Ada code) and
   then adafinal. It'll work.

-- 
Laurent Guerby <guerby@gnat.com>, Team Ada.
   "Use the Source, Luke. The Source will be with you, always (GPL)."





           reply	other threads:[~1997-12-19  0:00 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <349989C3.35F6@ibm.net>]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox