This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: EGCS-1.1.2: static class member not linking.
- To: egcs-bugs <egcs-bugs at egcs dot cygnus dot com>, egcs mailing list <egcs at egcs dot cygnus dot com>
- Subject: Re: EGCS-1.1.2: static class member not linking.
- From: Brendan Simon <brendan at dgs dot monash dot edu dot au>
- Date: Tue, 08 Jun 1999 04:03:51 +0000
- Organization: CTAM Pty Ltd
- References: <375C9099.A0D4DA78@dgs.monash.edu.au>
- Reply-To: brendan at dgs dot monash dot edu dot au
Don't worry about my previous mail. I am embarrassed to say that I made a
simple error. I forgot to initialise the static member in the .cc source
file. I have done this a few times in my class so I don't know why I
missed it this time; maybe I should get more sleep.
Thanks,
Brendan (blushing) Simon.
Brendan Simon wrote:
> egcs version 1.1.2.
> RedHat 5.2 GNU/Linux operating system
>
> I have a class with some data members being declared static. Some of
> the members link properly and some do not. I have the same problem with
> egcs-1.1.2 using cygwin. This sample program (invoked with g++ -Wall -o
> static.cc shows the problem.
>
> // FILE : static.cc
>
> class FOO
> {
> public :
> void f1();
> int a;
> static int b;
> };
>
> void FOO::f1()
> {
> a += b;
> }
>
> int main()
> {
> FOO foo;
> foo.f1();
> return 0;
> }
>
> // END : static.cc