[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: c++ include problem (preprocessor directives)



On Sat, 7 Aug 1999, Micha Feigin wrote:

> Date: Sat, 07 Aug 1999 13:48:48 +0300 (GMT+0300)
> From: Micha Feigin <michf@math.TAU.AC.IL>
> To: Debian-user <Debian-user@lists.DEBIAN.org>
> Subject: c++ include problem (preprocessor directives)
> Resent-Date: Sat, 07 Aug 1999 10:45:21 +0000
> Resent-From: debian-user@lists.DEBIAN.org
> Resent-cc: recipient list not shown: ;
> 
> In my files the headers are included like this:
> #ifdef NEWCPPH
> #include <iostream>
> #else
> #include <iostream.h>
> #endif
> 
> #include <cassert>
> #include <cstring>
> #include "input.h"
> 
> only then i get an error that the functions declared inside input.h can't
> be found. The linker says:
> g++ -o main.o -Wall -pedantic -c  main.cpp
> g++   main.o   -o main
> main.o: In function `main':
> main.o(.text+0x16): undefined reference to `input(void)'
> main.o(.text+0x8a): undefined reference to `input(char const *)'
> collect2: ld returned 1 exit status
> make: *** [main] Error 1
> 
> what am i doing wrong?

learn about C++ name mangling

extern "C" is your friend

> 
> thanx
> michf@math.tau.ac.il
> 
> 
> -- 
> Unsubscribe?  mail -s unsubscribe debian-user-request@lists.debian.org < /dev/null
> 
> 

                                     Oleg Krivosheev, 
                                     MS 220, BD/Physics,
                                     Fermi National Accelerator Laboratory,
                                     P.O.Box 500, Batavia, Illinois, 60510
                                     phone: (630) 840 8460
                                     FAX  : (630) 840 6039
                                     Email: kriol@fnal.gov


Reply to: