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,52882f38318f3520 X-Google-Attributes: gid103376,public From: comar@dantes.enst.fr (Cyrille Comar) Subject: Re: Linking an ADA routine to a program written in C Date: 1996/09/24 Message-ID: #1/1 X-Deja-AN: 185044981 distribution: world references: <51p2vu$enf@lal.interserv.com> <01bba5e0$cf06b040$328371a5@dhoossr.iquest.com> content-type: text/plain; charset=iso-8859-1 organization: ENST, France mime-version: 1.0 reply-to: comar@gnat.com newsgroups: comp.lang.ada Date: 1996-09-24T00:00:00+00:00 List-Id: >>>>> "David" == David C Hoos, writes: In article <01bba5e0$cf06b040$328371a5@dhoossr.iquest.com> "David C. Hoos, Sr." writes: David> This is an implementation-dependent thing. Generally what David> has to be done is to tell the Ada compiler that the routine David> is to be called by a C compilation unit. This is done with David> a pragma such a EXPORT or EXTERNAL, depending on the David> implementation. Consult your compiler documentation, David> looking especially for discussions of Interface David> Programming. David> Further, the issue of "withed" packages pretty much David> requires that your main program be an Ada program. If you David> already have a suitable "main" program written in C, you David> would need to put an Ada "wrapper" around the C main. The David> C main might have to be renamed, depending on the Ada David> implementation, because some Ada systems use a routine David> called "main", which would confuse the linker of there were David> two "main" symbols declared. Sorry to jump in a bit late on this thread but I just wanted to add that all the above description is perfectly correct for Ada83 but is far from the reality of Ada (Ada 95). Interfacing with most other languages is not implementation-defined anymore. This is perfectly well defined in the R.M. See description of pragma Import/Export and definition of standard procedures adainit (for elaboration of the Ada part when main is not in Ada) and adafinal (for finalization of the same Ada part). All of this is completely standard and implemented as required at least in GNAT but most probably in other Ada95 compilers as well. Cyrille