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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,703ebe6e4ca7960a X-Google-Attributes: gid103376,public From: Samuel Tardieu Subject: Re: Linking C++ and Ada Date: 1996/02/27 Message-ID: #1/1 X-Deja-AN: 141328152 sender: tardieu@gargantua.enst.fr references: content-type: text/plain; charset=iso-8859-1 organization: TELECOM Paris mime-version: 1.0 newsgroups: comp.lang.ada Date: 1996-02-27T00:00:00+00:00 List-Id: >>>>> "Scott" == Scott Moody, 773-8600 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 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