comp.lang.ada
 help / color / mirror / Atom feed
* Calling Ada from a non-Ada language
@ 1992-11-11 17:24 Rick Simonian
  0 siblings, 0 replies; 3+ messages in thread
From: Rick Simonian @ 1992-11-11 17:24 UTC (permalink / raw)


I'm sure that most will consider this to be gross and unwieldy,
but we need to be able to call Ada routines from non-Ada 
languages.  We first want to solve the problem from C; other
languages need to be addressed later.

I would like to know of any experience doing this in a Unix
environment, both where Ada is the main procedure, and where
C (for example) is the main procedure.  I'm aware of the
obvious problems: how to link the executable if Ada is not
the main, how to elaborate the Ada runtime, use of exceptions, 
passing complex structures, how tasking works, and so forth.

Ada provides a reasonable means of calling non-Ada routines,
but you hit a brick wall going the other way.  This problem
needs to be addressed in order to better integrate Ada into
a heterogeneous environment.

Rick Simonian
Harris Space Systems Corp.
simonian@x102a.ess.harris.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Calling Ada from a non-Ada language
@ 1992-11-11 22:40 david.c.willett
  0 siblings, 0 replies; 3+ messages in thread
From: david.c.willett @ 1992-11-11 22:40 UTC (permalink / raw)


>From article <1992Nov11.172455.11472@dale.ksc.nasa.gov>, by rsimonia@dale.ksc.
nasa.gov (Rick Simonian):
> 
> I'm sure that most will consider this to be gross and unwieldy,
> but we need to be able to call Ada routines from non-Ada 
> languages.  We first want to solve the problem from C; other
> languages need to be addressed later.

dcw-> You got that right, it's pretty gross and unwieldy, but what precisely
dcw-> do you mean by "call Ada routines from non-Ada languages"?  Do you 
dcw-> intend for a C function (possibly main) to call an Ada procedure?
dcw-> Would running the Ada units as a "detached" (in VMS-speak) or
dcw-> "child" process solve your problem?  Why do you need to do this
dcw-> anyway?

dcw->	(John Bentley, in "Programming Pearls" says to always ask that
dcw->	 last question).
dcw->
>
> I would like to know of any experience doing this in a Unix
> environment, both where Ada is the main procedure, and where
> C (for example) is the main procedure.  I'm aware of the
> obvious problems: how to link the executable if Ada is not
> the main, how to elaborate the Ada runtime, use of exceptions, 
> passing complex structures, how tasking works, and so forth.
> 
> Ada provides a reasonable means of calling non-Ada routines,
> but you hit a brick wall going the other way.  This problem
> needs to be addressed in order to better integrate Ada into
> a heterogeneous environment.
> 
> Rick Simonian
> Harris Space Systems Corp.
> simonian@x102a.ess.harris.com
>
 
-- 
Dave Willett          AT&T Federal Systems Advanced Technologies
attmail!dwillett      (AT&T FSAT)
-- Some girls don't like boys like me.... Oh but some girls do!
	-- Sawyer Brown

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Calling Ada from a non-Ada language
@ 1992-11-16 13:40 crispen
  0 siblings, 0 replies; 3+ messages in thread
From: crispen @ 1992-11-16 13:40 UTC (permalink / raw)


dale.ksc.nasa.gov!rsimonia@ames.arc.nasa.gov  (Rick Simonian)
asks about calling Ada from (e.g.) C.

We have done this, especially where early Ada bindings were absent
or broken (e.g., for DevGuide or SunView on the Sun), recognizing that we
would probably dump this code as soon as we got good bindings.

You *have* to have an Ada main(), so far as I know.  The reason is
that Ada does elaboration (sure of this) and task spawning (I think
this is what the code I've seen does) before it hits the first
line of main().  Obviously, C has never heard of either of these
activities as requirements before executing main().

We always had to fool around a bit with arguments before we got
things to work.  C calls by value and Ada calls by reference -- sometimes.
When?  You'll find out!  C strings don't look like Ada strings.  And Ada and
C structs sometimes need to be tweaked (the last two are true going either
way, of course).  For example, the following:

	struct foo {
		short	a;
		int	b;
		};

is 8 bytes long on the SPARC (have to look at ANSI C to see if this
is required or permitted).  Ada may have its own ideas about sizes
and alignments unless you give it a rep spec.  Don't rely on an Ada
record always matching a C struct.

Anyway, unless you're the only person in the world who wants to do
a particular job, you'll usually find Ada bindings that will let you
throw out your C-to-Ada code.  Eventually.
+-------------------------------+--------------------------------------+
| Bob Crispen                   |  Who will babysit the babysitters?   |
| crispen@foxy.boeing.com       +--------------------------------------+
| (205) 461-3296                |Opinions expressed here are mine alone|
+-------------------------------+--------------------------------------+

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1992-11-16 13:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1992-11-11 17:24 Calling Ada from a non-Ada language Rick Simonian
  -- strict thread matches above, loose matches on Subject: below --
1992-11-11 22:40 david.c.willett
1992-11-16 13:40 crispen

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