🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #576

g++ complains when static member is used.

#576
From: Michael Tiemann
Date: Tue, 14 Nov 1989 03:12
43 lines
1787 bytes
   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
Technical Details
Message-ID: <8911140312.AA06507@lurch.Stanford.EDU>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!ucsd!swrinde!gem.mps.ohio-state.edu!tut.cis.ohio-state.edu!LURCH.STANFORD.EDU!tiemann
References: <6459@merlin.usc.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!ucsd!swrinde!gem.mps.ohio-state.edu!tut.cis.ohio-state.edu!LURCH.STANFORD.EDU!tiemann
From: tiemann@LURCH.STANFORD.EDU (Michael Tiemann)
Newsgroups: gnu.g++.bug
Subject: g++ complains when static member is used.
Message-ID: <8911140312.AA06507@lurch.Stanford.EDU>
Date: 14 Nov 89 03:12:51 GMT
References: <6459@merlin.usc.edu>
Sender: daemon@tut.cis.ohio-state.edu
Reply-To: tiemann@lurch.stanford.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 43