> -----Original Message----- > From: ccostin [mailto:[EMAIL PROTECTED] > Sent: Monday, February 19, 2007 10:28 AM > To: debian-user@lists.debian.org > Subject: preprocessor/linker c++ error > > What's wrong with the followind C++ code ? > > $ cat file1.cc > #include "file.hh" > void f1(int x,int y, int z) > { > a=x; > b=y; > c=z; > } > > $ cat file2.cc > #include "file.hh" > void f2(int x,int y, int z) > { > a=x; > b=y; > c=z; > } > > $ cat file.hh > #ifndef _FIS_H_ > #define _FIS_H_ > int a,b,c; > void f1(int x,int y, int z); > void f2(int x,int y, int z); > #endif > > $ cat mult.cc > #include <stdio.h> > #include "file.hh" > > int main(int argc, char **argv) > { > f1(2,4,5); > f2(-4,-6,-7); > } >
In file.hh, put "extern" before "int a,b,c;". Then, in ONE .cc file, doesn't really matter which one, add "int a,b,c;". > At compilation some unexepected errors appear: > > g++ -g3 -Wall mult.cc file1.cc file2.cc file.hh -o mult Also, don't include file.hh on the command line to g++. -- Kevin -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]