[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [rtl] RTLinux: C++ static members != good ?



I sent an answer already. Got lost somehow.

Anyhow, the reason for this behavior is, that a static member is not just a
type definition, it is actually a real memory area. Therefor you have to
create a real variable therefore. I personally dont like that behavior, but
I think it was the only possible solution for C++. Again the reason is it
belongs to the class rather then to one of the objects.

What you have to add this to _one_ of the .cpp files:

int A::a;
or
int A::a=0;
if you want to initialize it


----- Original Message -----
From: "Evan Harvey" <poncholio@hotmail.com>
To: <rtl@rtlinux.org>
Sent: Wednesday, May 23, 2001 10:48 AM
Subject: [rtl] RTLinux: C++ static members != good ?


> I have modified the hello.cpp example that came with RTLinux.  I moved
class
> A to a.h and then moved class B declarations to b.h and implementation to
> b.cpp.
>
> I can compile and run the modules no problem.
>
> my problem comes when I try to make
> int a;  //from class A
> static int a;
>
> when I load the module I get an error like
>
> error in b.o :  unresolved symbol _1A.a
>
> Any clue why this is?  Can I not use static members with RTLinux?  What is
> an alternative to static?
>
> Thank you for your help.
>
> -Evan
> poncholio@hotmail.com
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com
>
> -- [rtl] ---
> To unsubscribe:
> echo "unsubscribe rtl" | mail majordomo@rtlinux.org OR
> echo "unsubscribe rtl <Your_email>" | mail majordomo@rtlinux.org
> --
> For more information on Real-Time Linux see:
> http://www.rtlinux.org/rtlinux/
>