comp.lang.ada
 help / color / mirror / Atom feed
From: Justin Braach <fxhunter@cs.montana.edu>
Subject: Re: linking with C++
Date: 1998/04/21
Date: 1998-04-21T00:00:00+00:00	[thread overview]
Message-ID: <353D4C33.988495D5@cs.montana.edu> (raw)
In-Reply-To: 6hglkj$dlh$1@nyheter.chalmers.se


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




      parent reply	other threads:[~1998-04-21  0:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-04-20  0:00 linking with C++ Martin Klang
1998-04-21  0:00 ` Robert Dewar
1998-04-23  0:00   ` [GNAT] Extending a C++ class Jacob Sparre Andersen
1998-04-21  0:00 ` linking with C++ Jerry van Dijk
1998-04-21  0:00 ` Robert Dewar
1998-04-21  0:00 ` Justin Braach [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