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.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!mnetor!tmsoft!torsqnt!lethe!yunexus!ists!helios.physics.utoronto.ca!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!cs.utexas.edu!yale!think.com!linus!linus!linus!mbunix!emery From: emery@aries.mitre.org (David Emery) Newsgroups: comp.lang.ada Subject: Re: Calling Ada routines from C programs. Message-ID: Date: 19 Feb 91 15:05:58 GMT References: <1884@array.UUCP> <91049.164842KKEYTE@ESOC.BITNET> Sender: news@linus.mitre.org (News Service) Organization: The Mitre Corp., Bedford, MA. In-Reply-To: KKEYTE@ESOC.BITNET's message of 18 Feb 91 16:13:08 GMT Nntp-Posting-Host: aries.mitre.org List-Id: Karl Keyte noted "the Ada system requires its complete environment in order to function". He's almost right. The real issue is elaboration. Before an Ada subprogram is called, it must be elaborated, along with everything it needs. Furthermore, library units must be elaborated before the main program starts. This is what must be done before a C program can invoke an Ada operation. On at least one compiler, there is a jump table containing the addresses of the elaboration routines for everything that needs to be elaborated before the main routine is invoked. This table is "sorted" in elaboration order (e.g. pragma ELABORATE, etc is taken into account.) It would be sufficient to have the C "_main" execute this code before (or during) the first call to any Ada routine. But, of course, how to do this is highly compiler-dependent. In the short run, Karl's technique (having an Ada wrapper invoke the C "_main" entry) should work. dave emery emery@aries.mitre.org