Skip to main content

__declspec question with intel c++

Submitted by lorien on
Forum

I've got 3 wrapper functions for dealing with thread local storage (to make it cross-platform):

void* LDK_API threadLocalGet(TLSKey key);
TLSKey LDK_API threadLocalCreateKey(ThreadLocalDtor dtor=NULL);
void LDK_API threadLocalSet(TLSKey key, void* data);

Intel C++ 7.1 tells me "#warning 903: __declspec attributes ignored void* LDK_API threadLocalGet(TLSKey key)"

It doesn't complain about either of the other functions, and none of them are inlines. This is during the building of the dll, so LDK_API resolves to __declspec(dllexport).

When I try to link with my dll it cannot find the threadLocalGet() symbol.

Anyone got a solution? Google isn't helping at all [:(]

Thanks

Submitted by Daemin on Fri, 08/04/05 - 3:55 AM Permalink

Is it meant to be returning a void pointer?

My suggestion would be to make the void* return value into a parameter that gets passed into the function, and possibly return int or bool from it to indicate a level of success etc.

The other thing to check out would be what you have before that function. Since it could be a parse error from some other section of code that's making the parser confused somewhat.

Submitted by lorien on Fri, 08/04/05 - 9:57 PM Permalink

actually the solution is to make the prototypes LDK_API void* threadLocalGet i.e. the declspec stuff goes first.

It is supposed to return a void*, that's just how thread local storage works...

Posted by lorien on
Forum

I've got 3 wrapper functions for dealing with thread local storage (to make it cross-platform):

void* LDK_API threadLocalGet(TLSKey key);
TLSKey LDK_API threadLocalCreateKey(ThreadLocalDtor dtor=NULL);
void LDK_API threadLocalSet(TLSKey key, void* data);

Intel C++ 7.1 tells me "#warning 903: __declspec attributes ignored void* LDK_API threadLocalGet(TLSKey key)"

It doesn't complain about either of the other functions, and none of them are inlines. This is during the building of the dll, so LDK_API resolves to __declspec(dllexport).

When I try to link with my dll it cannot find the threadLocalGet() symbol.

Anyone got a solution? Google isn't helping at all [:(]

Thanks


Submitted by Daemin on Fri, 08/04/05 - 3:55 AM Permalink

Is it meant to be returning a void pointer?

My suggestion would be to make the void* return value into a parameter that gets passed into the function, and possibly return int or bool from it to indicate a level of success etc.

The other thing to check out would be what you have before that function. Since it could be a parse error from some other section of code that's making the parser confused somewhat.

Submitted by lorien on Fri, 08/04/05 - 9:57 PM Permalink

actually the solution is to make the prototypes LDK_API void* threadLocalGet i.e. the declspec stuff goes first.

It is supposed to return a void*, that's just how thread local storage works...