delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/10/31/21:05:23

From: alaric AT abwillms DOT demon DOT co DOT uk (Alaric B. Williams)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: C/C++ libraries. Any difference?
Date: Thu, 31 Oct 1996 18:50:50 GMT
Lines: 39
Message-ID: <846787710.25292.1@abwillms.demon.co.uk>
References: <555rfu$maq AT nz12 DOT rz DOT uni-karlsruhe DOT de>
NNTP-Posting-Host: abwillms.demon.co.uk
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

un1t AT rz DOT uni-karlsruhe DOT de (Matthias Baas) wrote:

>Hi,

>I have a problem with libraries and C/C++. Is there a difference
>between a library for C and a library for C++?

Yes... there's a difference, in fact, in the way the names of things
are stored in object files, library files, and debug information. It's
called C++ name mangling, and it basically means that the names
actually used have things stuck on the end.

For example:

int MyFunc(char *ch);

in C compiles to somethign called _MyFunc, whereas in C++ it ends up
looking more like _MyFunc^*£$£%some_garbage%^$"%...

To join C things to C++ things, use this syntax:

extern "C" int MyFunc(char *ch);

which tells the compiler you want to use the old C notation. If you go
through the header files for libpng and stick "C" after every Extern
you see, things should be nicer.


ABW
---

COMPUTER: We are in position over the Rebel homeworld.
VADAR: Engage the Death Star primary weapon, let those rebel worms die!
COMPUTER: Sorry, your evaluation version of Battle Computer 3.0 has expired. 
          Please send 2.6 billion dollars to the address in REGISTER.TXT

Alaric B. Williams Internet : alaric AT abwillms DOT demon DOT co DOT uk
<A HREF="http://www.abwillms.demon.co.uk/">Hello :-)</A>

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019