Message-ID: <3887A562.12D15B9A@connection.com> Date: Thu, 20 Jan 2000 19:16:37 -0500 From: sam X-Mailer: Mozilla 4.6 [en] (Win95; I) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp Subject: Re: libraries headaches References: <388637B2 DOT 333A30C6 AT connection DOT com> <8671ho$co6$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 216.13.79.92 X-Trace: 20 Jan 2000 19:13:53 -0500, 216.13.79.92 Lines: 56 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Hans-Bernhard Broeker wrote: > sam wrote: > [...] > > So who can tell me how to name my functions so that I can write C++ code > > and libraries. > > Your problem, most probably, is not with C++ itself, or the names of > your functions. It's with *mixing* C and C++ parts (C library, C++ > main program) in the same program. > Actually, I had both compiled as C++ but when it didn't work I have changed the main program to 'C'. Now that I think about it there is no sense to have libraries in C++ if most of the program is not. Shouldn't even be possible. > > > I have stumbled across the term 'name mangling'??? > > That's exactly your problem, I suspect. C++ adds information to the > names of objects (variables, functions) to carry type information, for > things like polymorphism, i.e. a function > > int dosomething(double arg1, char *arg2); > > may become the following linker-visible symbol: > > .globl dosomething__FdPc > > C doesn't do that, so the same function would be compiled to > > .globl dosomething_ > > and that's it. To avoid this, you have to *tell* the C++ compiler that > an external function declaration (prototype in a header) is for a > C, not a C++ function. > > extern "C" { > /* C declarations here */ > } > So that's what that is for. > > does that for you. Read up the details in Stroustrup or some other C++ > textbook. > > -- > Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de) > Even if all the snow were burnt, ashes would remain. Thank you for your time.