comp.lang.ada
 help / color / mirror / Atom feed
From: Samuel Tardieu <sam@inf.enst.fr>
Subject: Re: Linking C++ and Ada
Date: 1996/02/27
Date: 1996-02-27T00:00:00+00:00	[thread overview]
Message-ID: <qw6enrhkqr4.fsf@gargantua.enst.fr> (raw)
In-Reply-To: DnE8s6.J5n@plato.ds.boeing.com

>>>>> "Scott" == Scott Moody, 773-8600 <scott@hakuin.boeing.com> writes:

Scott> This brings up a question. GNAT has a few pragmas for linking
Scott> to C++ that are not part of the Ada standard. I haven't even
Scott> seen them until looking at the ex6 example. Should I start
Scott> using these non-standard pragmas? It would definitely help my
Scott> corba interface...

C++ compilers each have their own way of mangling function names to
support overloading. The interface between Ada and C++ implies that
the Ada compiler knows how the C++ compiler changes the function
names. Moreover, there is actually no standard way of implementing
dispatch tables in C++, so this is one more piece of information that
the Ada compiler must know.

Since GNAT and g++ use the same back-end to generate the machine code,
GNAT should do a pretty good job in interfacing with C++. I cannot
imagine how another compiler vendor which does not provide its own C++
compiler could implement this in a better way.

But of course, if you want to stay truly portable, you should
definitively *NOT* use these pragmas and forgive the idea of mixing
C++ and Ada classes :)

  Sam

PS/ as an example, here are the linker names defined by CC and g++ (on
    a Solaris machine) for the following C++ file:

    t.C
    ===
    #include <string.h>
    int f(int x){return x;}
    int f(char *x){return strlen(x);}
    int f(char x){return x;}

    CC
    ==
    __0FBfi
    __0FBfPc
    __0FBfc

    g++
    ===
    f__Fi
    f__FPc
    f__Fc
--
"La cervelle des petits enfants, ca doit avoir comme un petit gout de noisette"
                                                       Charles Baudelaire




  reply	other threads:[~1996-02-27  0:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-02-22  0:00 Linking C++ and Ada Howard A. Free
1996-02-22  0:00 ` Gilles Demailly
1996-02-26  0:00   ` Scott Moody, 773-8600
1996-02-27  0:00     ` Samuel Tardieu [this message]
1996-02-22  0:00 ` Nasser Abbasi
  -- strict thread matches above, loose matches on Subject: below --
1996-02-23  0:00 Simon Johnston
replies disabled

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