Mail Archives: djgpp/1996/12/26/20:49:35
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 -