tiemann@LURCH.STANFORD.EDU (Michael Tiemann) (11/14/89)
Date: 14 Nov 89 01:23:34 GMT
From: xz@aludra.usc.edu (Xiaofeng Zhao)
Organization: University of Southern California, Los Angeles, CA
Sender: bug-g++-request@prep.ai.mit.edu
In the following C++ toy program, g++-1.36.1 complains about
the multiple definition when static member is used. I am not
sure if this is a bug or a feature. The experiments are
conducted on both SUN3/60M and SUN4/260 under OS 4.0.3,
respectively.
Script started on Mon Nov 13 17:02:00 1989
[1]: cat def.h
#include <stream.h>
class foo {
private:
static int how_many = 0;
public:
foo ();
~foo ();
void identify ();
};
[...]
[6]: g++ -o foo -v def.o main.o -lg++ -lm
gcc version 1.36.1 (based on GCC 1.36)
/usr/usc/lib/gcc-ld -o foo -e start -dc -dp /lib/crt0.o def.o main.o -lg++ -lm -lg++ /usr/usc/lib/gcc-gnulib -lc
def.cc:0: Definition of symbol foo::how_many (multiply defined)
main.cc:0: Definition of symbol foo::how_many (multiply defined)
[7]: exit
[8]:
script done on Mon Nov 13 17:03:20 1989
It's a feature. You could get the same result if you had
int i = 0;
in your header files, and you included it multiple times.
Michael