comp.lang.ada
 help / color / mirror / Atom feed
From: emery@aries.mitre.org (David Emery)
Subject: Re: Calling Ada routines from C programs.
Date: 19 Feb 91 15:05:58 GMT	[thread overview]
Message-ID: <EMERY.91Feb19100558@aries.mitre.org> (raw)
In-Reply-To: KKEYTE@ESOC.BITNET's message of 18 Feb 91 16:13:08 GMT

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

  reply	other threads:[~1991-02-19 15:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1991-02-15 18:14 Calling Ada routines from C programs Mark Culp
1991-02-18  0:23 ` Jim Showalter
1991-02-18 16:14   ` Karl Keyte
1991-02-19 15:05     ` David Emery [this message]
1991-02-19 19:37       ` Bruce Bauman
replies disabled

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