From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ef3ff2cf59eff560 X-Google-Attributes: gid103376,public From: Ara Kassabian Subject: Re: Help with Gnat Cross-compile Date: 1998/04/16 Message-ID: <6h57uk$d2s@bgtnsc02.worldnet.att.net>#1/1 X-Deja-AN: 344687646 Content-Transfer-Encoding: 7bit References: <6gtil3$jdi$1@hirame.wwa.com> Content-Type: text/plain; charset=us-ascii Organization: AT&T WorldNet Services Mime-Version: 1.0 Reply-To: akass@worldnet.att.net Newsgroups: comp.lang.ada Date: 1998-04-16T00:00:00+00:00 List-Id: Samuel G. Williams wrote: > > I am looking for good examples on two scenarios. The first is the compile of > Ada code for later linking in C. I would also like any recommendations for call > converntions. Second I am looking for the reverse. Being able to compile c > then link in with Ada also with the calling conventions. I am currently > attempting to help a friend without an Internet connection obtain this > information. I would welcome all replies. BTW he is using GNAT on a Solaris > workstation. He found brief entries in the GNAT UG but didn't quite > understand them well enough to be useful. > > Thanks in advance for your help. > In Ada-83, interfacing with C was as easy as using the right pragmas, so long as you didn't run into threading issues (both the C and Ada-83 parts of our program were threaded, and the two threading packages were not aware of each other). It *should* be just as easy with GNAT. The procedure should be: 1. Calling C from Ada: Write a package spec declaring the C functions and using "pragma import", so Ada knows it needs to use C calling conventions. 2. Calling Ada95 from C: Write a header file with the Ada95 function/procedure prototypes. If you cannot turn off name mangling in Ada95 using a pragma, then you need to compile your files, figure out the mangled names by looking in the object files and use those as your function names in your C header files. You make things look pretty by using #define to create unmangled aliases for the mangled functions. You *may* run into problems with Ada95 procedures. I am not sure if they equate to void functions in C. ------------------------------------------------------ Ara Kassabian akass@worldnet.att.net akassabian@logicon.com (work) ------------------------------------------------------