delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/12/01/01:46:39

From: ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Killing C++ name mangling
Date: 1 Dec 1997 05:54:22 GMT
Organization: The National Capital FreeNet
Lines: 18
Message-ID: <65tjee$1jm@freenet-news.carleton.ca>
References: <tmoBYFAPjQg0EwOZ AT foobar DOT co DOT uk> <34812A1A DOT 316B8A0D AT alcyone DOT com>
Reply-To: ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire)
NNTP-Posting-Host: freenet3.carleton.ca
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp


If you need to compile this C code and later link it with C++ code, do this:

* Compile as C, make object files or a library file. Make header files.
  Wrap the >header file declarations< in extern "C".
* Include header files in C++ source, link C++ object modules so generated
  with the C object files.

This is done by the libc library itself: it is written in C, and if you
look at the headers (such as stdio.h) you see the extern "C" and how they
are used for this, and lastly, you'll notice libc functions like printf link
with C++ object code fine.
--
    .*.  Where feelings are concerned, answers are rarely simple [GeneDeWeese]
 -()  <  When I go to the theater, I always go straight to the "bag and mix"
    `*'  bulk candy section...because variety is the spice of life... [me]
Paul Derbyshire ao950 AT freenet DOT carleton DOT ca, http://chat.carleton.ca/~pderbysh

- Raw text -


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