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.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3db3a64384280d0f X-Google-Attributes: gid103376,public From: Stephen Leake Subject: Re: Ada to C++ communication under NT4.0 Date: 1998/08/13 Message-ID: <35D2DA1B.64D7@erols.com>#1/1 X-Deja-AN: 380725760 Content-Transfer-Encoding: 7bit References: <01bdc0c8$e8a76a80$0f010180@nc84c> <35c8ecf5.0@news1.ibm.net> <01bdc494$f3eab0d0$0f010180@nc84c> Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@rcn.com X-Trace: winter.news.erols.com 903010959 8597 207.172.137.22 (13 Aug 1998 12:22:39 GMT) Organization: LeakyStain Mime-Version: 1.0 Reply-To: leakstan@erols.com Newsgroups: comp.lang.ada Date: 1998-08-13T00:00:00+00:00 List-Id: Mark wrote: > > I am well aware that there is nothing magic about an Ada executable! The > main question concerns a C application and an Ada application running under > NT4.0 which require to share a large amount of data, therefore creating > significant overhead in terms of speed and memory usage if sockets or > mailboxes are used. Shared memory would seem the best option in this case. > > Someone has > suggested linking the two images together using our GNAT compiler. Is this > possible? I would not have thought so since presumably the Ada and C > applications would require separate run time systems to handle their > tasking. There are two issues in combining C++ and Ada into a single executable: object file format and elaboration/finalization. The current fully supported version of the GNAT compiler (3.11?) supports the Microsoft object format, so it can link C++ compiled with MS C++ with Ada compiled by GNAT. The current public version of GNAT (3.10) can't do this. However, ObjectAda from Aonix uses the MS object file format for Ada code; it can link with MS C++. Note that Borland uses a different object file format, and can't link with any of these. Another way around the object file format problem is to make DLLs. In my current application, I use ObjectAda to make a DLL, and call it from Borland C++. GNAT can also make DLLs. The elaboration/finalization problem is solved by explicitly calling the elaboration and finalization code that is normally called by "main". In general, you can have either an Ada main that explicitly calls the C++ stuff, or a C++ main that explicitly calls the Ada stuff. The GNAT user's guide has good instructions on how to call the GNAT elaboration/finalization code. Multi-language programming is the best way to introduce people to Ada! -- Stephe