From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.1 required=3.0 tests=BAYES_00,FROM_NO_USER autolearn=no autolearn_force=no version=3.4.5-pre1 Date: Mon, 16 Nov 92 07:40:27 CST From: crispen <@ada3.ca.boeing.com:crispen@efftoo.boeing.com> Subject: Re: Calling Ada from a non-Ada language Message-ID: <9211161340.AA29041@efftoo.boeing.com> List-Id: 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| +-------------------------------+--------------------------------------+