delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/12/26/20:49:35

From: Erik Max Francis <max AT alcyone DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Cannot Link PDCURSES To C++ Programs.
Date: Thu, 26 Dec 1996 13:58:18 -0800
Organization: Alcyone Systems
Lines: 24
Message-ID: <32C2F4FA.7E7861FC@alcyone.com>
References: <199612270005 DOT WAA06404 AT cosmos DOT hiway DOT gr>
NNTP-Posting-Host: newton.alcyone.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Panos Platon Tsapralis wrote:

>         I experience a strange problem : I write  a program that uses the
> PD_Curses package. The file name extension of the program is ".c" and it
> flawlessly compiles & links. When I rename it to ".cpp" extension, it
> compiles but during linking it complains about "Undefined references to
> ." all Curses-specific functions that I use. What is it that I do wrong ?

You need to wrap extern "C" { ... } around the place where the curses
package is included.  (Optimally this should be in the header file for
curses itself.)

C and C++ have different symbol naming conventions, and so two functions
which are otherwise identical [say, int f(void)] will be referenced with a
different symbol in C vs. C++.  If you're including a C header, you need to
explicitly state this in a C++ program, because otherwise the linker won't
know which symbol-naming scheme to look for at link time.

-- 
                             Erik Max Francis | max AT alcyone DOT com
                              Alcyone Systems | http://www.alcyone.com/max/
                         San Jose, California | 37 20 07 N 121 53 38 W
                                 &tSftDotIotE | R^4: the 4th R is respect
     "You must surely know if man made heaven | Then man made hell"

- Raw text -


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