www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/21/21:54:25

From: Ian D Romanick <idr AT cs DOT pdx DOT edu>
Message-Id: <199709220153.SAA22662@sirius.cs.pdx.edu>
Subject: Re: cc and c-Libraries
To: mfreund AT physik DOT tu-muenchen DOT de (Martin Freund)
Date: Sun, 21 Sep 1997 18:53:02 -0700 (PDT)
Cc: djgpp AT delorie DOT com
In-Reply-To: <3423BC1E.CAE@physik.tu-muenchen.de> from "Martin Freund" at Sep 20, 97 02:05:50 pm
MIME-Version: 1.0

> I have problems in linking my c library-files to my cc main programm.
> When I compile the c library-files as cc-files, the problem disappears.
> But I donīt want to store two different versions of my libraries, one
> for cc main-files and one for the c main-files. 

By "cc" I assume that you mean C++?  The problem is, C++ does "name
mangling".  That is, stuff is added to function names to encode information
about the number and types of parameters.  Your C libraries will, obviously,
not have this.  If you want to link a C compiled function with a C++ program
you need to do something like this:

extern "C"
{
int foo( int, int );
};

Virtually any book on C++ (and probably the DJGPP faq) will explain this
further.

-- 
"Don't waste our bandwidth with cliched catch phrases that were moldy
years ago. Be creative- surely with the plethora of bodily fluids, and
other excereta to draw upon you can come up with something a little more
original" -- Rhias K. Hall (badger AT wizards DOT com)

- Raw text -


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