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,fcbbb6164185a4a7 X-Google-Attributes: gid103376,public From: Justin Braach Subject: Re: linking with C++ Date: 1998/04/21 Message-ID: <353D4C33.988495D5@cs.montana.edu>#1/1 X-Deja-AN: 346497494 Content-Transfer-Encoding: 7bit References: <6hglkj$dlh$1@nyheter.chalmers.se> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Organization: Joe Local L-User. Newsgroups: comp.lang.ada Date: 1998-04-21T00:00:00+00:00 List-Id: Martin Klang wrote: > > lately i've been trying out ADA, and even though it's not by a long way as > esthetically pleasing as C++, i must confess it's a pretty useful little > language. > Heh... little... Maybe for an elephant. <...> > > i cannot link to C++ with gnatlink. > <...> > > it seems to have no importance in this example whether i use pragma C or CPP > (what is the difference anyhow?) > > comparing c.o and cc.o yields that g++ somewhere along the line renamned the > c_test-function to c_test__Fv. Why??? That has to do with C++'s wonderful name mangling stuff. Don't ask, 'cause I don't know. Anyhow if you look in any Standard C header file, (not C++), you _should_ see at the beginning somewhere a: #ifdef __cplusplus extern "C" { #endif or something like it. That funny little "extern "C"" forces the compiler not to screw up the names of functions and variables. Anyhow, at the beginnings of any function prototypes, put that phrase, such as: extern "C" void foo(void); This way, you can import the function into Ada, or even C if it's being compiled as a separate object. There is, (I believe), a "C++" version of that phrase that should work with the CPP Ada pragma, but I'm not sure, (never tried). I had much fun linking Ada and C/C++ together recently, so I know how good a time you are having. I won't go on about my thoughts concerning the different languages, so... The GNAT manual also describes how to compile Ada modules for C/C++ main functions. You might wanna look at that too. Hope this helps, Justin -- "Never solve puzzles that open the gates of Hell..." fxhunter@cs.montana.edu http://www.cs.montana.edu/~fxhunter