comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@merv.cs.nyu.edu (Robert Dewar)
Subject: Re: Help with Gnat Cross-compile
Date: 1998/04/17
Date: 1998-04-17T00:00:00+00:00	[thread overview]
Message-ID: <dewar.892815291@merv> (raw)
In-Reply-To: 6h57uk$d2s@bgtnsc02.worldnet.att.net


Ara said

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


This is completely incorrect advice if you are using Ada 95. Things are
FAR simpler and FAR more portable in Ada 95, and indeed most of what you
need and want is right there in annex B in the RM. There is no need to
investigate mysterious system dependent "mangling" what ever that might be!

Indeed the advice as given in section 2 above is not even correct for Ada 83,
since it ignores elaboration issues, which often proved extremely difficult
to solve in Ada 83. Again in Ada 95, you can look in the RM to find out how
to handle the elaboration problem.





      reply	other threads:[~1998-04-17  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
1998-04-17  0:00   ` Robert Dewar [this message]
replies disabled

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