comp.lang.ada
 help / color / mirror / Atom feed
From: Ara Kassabian <akass@worldnet.att.net>
Subject: Re: Help with Gnat Cross-compile
Date: 1998/04/16
Date: 1998-04-16T00:00:00+00:00	[thread overview]
Message-ID: <6h57uk$d2s@bgtnsc02.worldnet.att.net> (raw)
In-Reply-To: 6gtil3$jdi$1@hirame.wwa.com


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)
------------------------------------------------------




  reply	other threads:[~1998-04-16  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-04-13  0:00 Help with Gnat Cross-compile Samuel G. Williams
1998-04-16  0:00 ` Ara Kassabian [this message]
1998-04-17  0:00   ` Robert Dewar
replies disabled

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