public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* error : multiple definition of
@ 2002-10-17  7:19 zhjin
  0 siblings, 0 replies; only message in thread
From: zhjin @ 2002-10-17  7:19 UTC (permalink / raw)
  To: gcc

hi
  this is my code under redhat linux 8.0.

//a.h
#ifndef ah
#define ah
int i;
void add();
#endif 

//a.cpp
#include "a.h"
void add(){
  i++;
}

//c.cpp
#include "a.h"
int main(){
  i = 100;
  add();
  return 0;
}

g++ -c a.cpp     success
g++ c.cpp a.o 
error: a.o(.bss+0x0): multiple definition of 'i'
/tmp/cc0q7tmK.o(.bss+0x0): first defined here
collect2: ld returned 1 exit status.

can someone help me to solve problem? 
thanks.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-10-17  5:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-17  7:19 error : multiple definition of zhjin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).