comp.lang.ada
 help / color / mirror / Atom feed
From: ludovic.brenta@insalien.org (Ludovic Brenta)
Subject: Re: Latest GNAT configuration
Date: 13 Sep 2002 09:24:24 -0700
Date: 2002-09-13T16:24:24+00:00	[thread overview]
Message-ID: <214d6b7.0209130824.366d5ee4@posting.google.com> (raw)
In-Reply-To: d243f788.0209041414.76fe1d79@posting.google.com

On 4 Sep 2002 15:14:28 -0700
matthewmajka@mac.com (Matt Majka) wrote:
> All C and C++ code will be using GCC 3.1.1.  I hope to use the Ada
> compiler in GCC 3.1.1 as well, but there appear to be GDB deficiencies
> at this time.  I am wondering if there are any known problems with
> using GCC 2.8.1 for Ada and GCC 3.1.1 for all other code (C and C++)
> in the same binary.

FWIW, I had a toy shared library/DLL written in Ada calling callbacks
from the main program written in C.  On Windows, I used MinGW 2.0.0 gcc
3.2 for the Ada source, and Metrowerks CodeWarrior 7.2 for the C source.
On Linux I used gnat 3.13p (RPM) and gcc 3.0.1 respectively.  I found
the interfaces to work flawlessly (granted, I only did limited testing).

However, as someone else pointed out, the C++ ABI's are different
between versions of GCC.  They may also be different between compilers. 
So, my advice would be to make sure you use C (not C++) interfaces
between your Ada and your non-Ada code.

To achieve this, for Ada code that exports subprograms, use Pragma
Export(C) not C++ and in the C/C++ header files use extern "C" to
import the subprograms.  If you want to call C++ code from Ada, you'd
need to write a C wrapper and import the C wrapper from Ada using Pragma
Import(C).

On Windows, there are additional steps to take if you want to write a
DLL in Ada and call it from non-GCC compilers.  These steps are to
create a library definition file (.def) using gnatlink
-Wl,--output-def,library.def; and then to create an import library from
the def file.  To create the import library, you need Microsoft's
librarian (LIB.EXE) and linker (LINK.EXE) which come with the Windows
SDK.  I've found this to be necessary when compiling the client code
with CodeWarrior.  Perhaps it will also be necessary if mixing versions
of GCC on Windows.

HTH

--
Ludovic Brenta



      reply	other threads:[~2002-09-13 16:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-27 16:35 Latest GNAT configuration Matt Majka
2002-08-27 18:16 ` Florian Weimer
2002-09-03 18:17   ` Matt Majka
2002-09-03 18:23     ` Samuel Tardieu
2002-09-04 22:14       ` Matt Majka
2002-09-13 16:24         ` Ludovic Brenta [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