comp.lang.ada
 help / color / mirror / Atom feed
From: crispen <@ada3.ca.boeing.com:crispen@efftoo.boeing.com>
Subject: Re: Calling Ada from a non-Ada language
Date: Mon, 16 Nov 92 07:40:27 CST	[thread overview]
Message-ID: <9211161340.AA29041@efftoo.boeing.com> (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|
+-------------------------------+--------------------------------------+

             reply	other threads:[~1992-11-16 13:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1992-11-16 13:40 crispen [this message]
  -- strict thread matches above, loose matches on Subject: below --
1992-11-11 22:40 Calling Ada from a non-Ada language david.c.willett
1992-11-11 17:24 Rick Simonian
replies disabled

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