From: "Stanley R. Allen" <s_allen@hso.link.com>
Subject: Re: C++ to Ada Link Problems
Date: 1998/02/27
Date: 1998-02-27T00:00:00+00:00 [thread overview]
Message-ID: <34F71D58.2781@hso.link.com> (raw)
In-Reply-To: 34F6CC30.D8B74ACB@mps.lmtas.lmco.com
James Huckaby wrote:
>
>
> Simply put, is it at all possible with the resources I have now
> (Sun Ada 2.1 and Sun C++ 3.0, upgrading soon to Sun Ada 3.0, and
> Sun C++ 4.0) to link Ada and C++?
"Linking C++ and Ada" is an umbrella topic. You might mean
by this that you need to "interface" Ada and C++. If so, you
may need to set up some C code which calls the C++ code,
and interface the Ada to this using pragma Interface.
But by the wording of your question, I suppose that you
have alreasy worked out those issues and are trying now
to build an executable. The main issue is C++ constructor/
deconstructor ("Xtor") operations for statically-declared
object instances: how do they get called? In Ada, global
variable initialization is defined in the language as
part of the elaboration process. In C++, it is the
job of external tools. A common way of creating the
contructor/destructor caller is to "munch" the object
code produced by the C++ compiler (using a munching
tool), which will produce a C file that calls the
Xtors. Compiling this C file and linking the new
object module with the C++ code will ensure that the
C++ static objects are constructed properly. To link
with Ada, ensure that the object file created from
the C program is included as one of the inputs to the
linker building the Ada main. (Since you are talking
about Ada 83, I assume that the main program is in Ada.)
My understanding is that munching is the approach
used by the GNU C++ implementation.
Other C++ compilers don't require a separate munching
phase, but expect that the linker will include calls
to the proper contructor/destructors. If the Ada
binding program (I think that would be a.ld for SunAda)
is used to create the Unix "ld" command, then the
stuff C++ needs will not be included. I'm not sure how
it works on the Sun; on the SGI with Delta C++ you can
specify that the C++ compiler itself ("CC") be used as
the linker. This will include the necessary code to
call the Xtor operations for static C++ objects.
Disclaimer: I have only done the above with GNAT, but
I believe the same principles apply when linking code
produced by other Ada compilers.
--
Stanley Allen
mailto:s_allen@hso.link.com
next prev parent reply other threads:[~1998-02-27 0:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <9802271359.AA07254@nile.gnat.com>
1998-02-27 0:00 ` C++ to Ada Link Problems James Huckaby
1998-02-27 0:00 ` Larry Kilgallen
1998-02-27 0:00 ` Robert Dewar
1998-02-28 0:00 ` Larry Kilgallen
1998-02-27 0:00 ` Stanley R. Allen [this message]
1998-02-27 0:00 ` James Huckaby
1998-02-27 0:00 ` Stanley R. Allen
1998-02-28 0:00 ` Simon Wright
1998-02-27 0:00 ` Robert Dewar
1998-02-25 0:00 James Huckaby
[not found] ` <9802270246.AA28724@MERV.CS.NYU.EDU>
1998-02-27 0:00 ` James Huckaby
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox