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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,bf1c1ed22d81eb7e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-09-13 09:24:24 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: ludovic.brenta@insalien.org (Ludovic Brenta) Newsgroups: comp.lang.ada Subject: Re: Latest GNAT configuration Date: 13 Sep 2002 09:24:24 -0700 Organization: http://groups.google.com/ Message-ID: <214d6b7.0209130824.366d5ee4@posting.google.com> References: <87lm6sjhga.fsf@deneb.enyo.de> <87znuzorto.fsf@inf.enst.fr> NNTP-Posting-Host: 168.159.1.94 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1031934264 23594 127.0.0.1 (13 Sep 2002 16:24:24 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 13 Sep 2002 16:24:24 GMT Xref: archiver1.google.com comp.lang.ada:28945 Date: 2002-09-13T16:24:24+00:00 List-Id: 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