How to get __declspec(thread) working on Windows CE

619 views Asked by At

I have a class containing:

class SomeClass {
    SomeClass *previous;
    static __declspec(thread) SomeClass *stackTop;

public:
    SomeClass() : previous(stackTop) { stackTop = this; }
    ~SomeClass() { stackTop = previous; }
};

__declspec(thread) SomeClass *SomeClass::stackTop = NULL;

This compiles fine for Win32 target, but when compiling for Pocket PC 2003 (ARMV4) fails with error C2485:

error C2485: '$I' : unrecognized extended attribute

in the two places where I set the member in SomeClass constructor and destructor and in all places where I instantiate SomeClass (it is instantiated as automatic variable and needs to know where the next instance higher up the stack is).

Unfortunately the error has no meaningful documentation in MSDN and the documentation for __declspec(thread) does not indicate any conditions under which it will not work. I did check that thread is not defined in preprocessor.

1

There are 1 answers

1
Miron Vranješ On BEST ANSWER

I don't believe that version of Pocket PC (Windows CE) supports the __declspec(thread) attribute (TLS). It would explain why this only comes up when you're compiling for Pocket PC but not for Win32. See the following links: