home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!charon.amdahl.com!pacbell.com!decwrl!sdd.hp.com!saimiri.primate.wisc.edu!zaphod.mps.ohio-state.edu!cs.utexas.edu!wupost!uwm.edu!linac!att!ucbvax!efftoo.boeing.com!crispen
- From: crispen@efftoo.boeing.com (crispen)
- Newsgroups: comp.lang.ada
- Subject: Re: Calling Ada from a non-Ada language
- Message-ID: <9211161340.AA29041@efftoo.boeing.com>
- Date: 16 Nov 92 13:40:27 GMT
- Sender: daemon@ucbvax.BERKELEY.EDU
- Distribution: world
- Organization: The Internet
- Lines: 37
-
- 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|
- +-------------------------------+--------------------------------------+
-