开发者

How to get __declspec(thread) working on Windows CE

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 fin开发者_StackOverflowe 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.


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:

  • Windows CE does not support the __declspec(thread) attribute
  • __declspec (thread) returns error
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜