From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.7 required=5.0 tests=BAYES_00,INVALID_DATE, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,bd85303b24b257e2 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1994-11-10 23:33:16 PST Newsgroups: comp.lang.ada Path: nntp.gmd.de!xlink.net!scsing.switch.ch!swidir.switch.ch!univ-lyon1.fr!pasteur.fr!jussieu.fr!oleane!pipex!uunet!psinntp!shellgate!camo!rgh From: Richard G. Hash Subject: Re: Calling C++ from within ADA Message-ID: Keywords: C++ ADA Sender: usenet@shellgate.shell.com (USENET News System) Reply-To: rgh@shell.com Organization: Shell Bellaire Research Center References: Date: Tue, 8 Nov 1994 18:34:49 GMT Date: 1994-11-08T18:34:49+00:00 List-Id: In 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