This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: EGCS-1.1.2: static class member not linking.


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]