comp.lang.ada
 help / color / mirror / Atom feed
From: Richard G. Hash <rgh@shell.com>
Subject: Re: Calling C++ from within ADA
Date: Tue, 8 Nov 1994 18:34:49 GMT
Date: 1994-11-08T18:34:49+00:00	[thread overview]
Message-ID: <rgh.784319689@camo> (raw)
In-Reply-To: CVANOVER.1.0007E49E@bamanet.ua.edu

In <CVANOVER.1.0007E49E@bamanet.ua.edu> CVANOVER@bamanet.ua.edu writes:
> Is there a way to call a C++ procedure from within ADA?
> I am using IBM AIX on an RS6000.

Unless I'm missing something you've got a link problem - both Ada
and C++ want control first (before main) for "elaboration" (and whatever
C++ calls it). A normal (AIX) C++ application uses /bin/xlC to link,
which actually creates a little tmp file with the cdtors table
in it, and links it in (you can see this being generated by munch if
you use "xlC -#").

You'll find that the crt0.o being linked in by C++ isn't the
one in /usr/lib/crt0.o, it's in /usr/lpp/xlC/lib/crt0.o, and it
has a call to "__C_runtime_startup()" in it.

We got around this by generating the ld script for the Ada program
(using an Ada main), and then linking in the generated cdtors
table and manually calling _C_runtime_startup () first thing
in our Ada main (we were linking in a C++ Dynatext library).

Yes, it's ugly; no, it's not portable; no, I can't even guarantee
it will always work (I just found _C_runtime_startup in crt0 and
said "hmm, looks suspicious, wonder what happens if you call it?").

If there is a cleaner solution then I would like to hear it (it took
me two months to convince Dynatext their library was in C++ (prior
versions were in C), and then all they said was "how about that?",
and didn't offer any solutions).

--
Richard G. Hash                                      email: rgh@shell.com
Shell Development Company, Bellaire Research Center  phone: (713) 245-7311
Member Team Ada                Free Ada94 compilers: cs.nyu.edu:/pub/gnat



      parent reply	other threads:[~1994-11-08 18:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1994-11-03 12:53 Calling C++ from within ADA CVANOVER
1994-11-03 15:11 ` Norman H. Cohen
     [not found] ` <CypvDM.8q5@nntpa.cb.att.com>
1994-11-04 17:31   ` Greg Harvey
1994-11-04 17:46     ` Greg Harvey
1994-11-07  2:52 ` Oliver E. Cole
1994-11-08 15:22 ` Eric Beser
1994-11-08 18:34 ` Richard G. Hash [this message]
replies disabled

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