I try to summing up all things:
I try to export thread local storage (dllexport)
from firstmodule and import in secondmodule (dllimport) but with no effect.
In firstmodule I have Includes/ThreadLocalStorage.h with delaration:
#include
namespace threads {
extern __declspec(dllexport)
boost::thread_specific_ptr<int> TlsStorage;
extern __declspec(dllexport) int
tls_value_storage = 0;
}
integer tls_value_storage is for testing purpose only. There is also
Src/ThreadLocalStorage.cpp with:
#include
namespace threads {
__declspec(dllexport)
boost::thread_specific_ptr<int> TlsStorage;
extern __declspec(dllexport) int
tls_value_storage;
}
and the last one: in stdafx.h in secondmodule module:
namespace threads {
extern __declspec(dllimport)
boost::thread_specific_ptr<int> TlsStorage;
extern __declspec(dllimport) int
tls_value_storage2;
}
But after all when I try to change set tls in secondmodule
threads::TlsStorage.reset(&new_language_value);
int *sanity_check = threads::TlxStorage.get(); //.get()
return proper value
Funtion();
Now we go to the firstmodule, function() (using the same thread)
int sanity_check_1 = threads::tls_value_storage; //Proper
value
int *sanity_check_2 = threads::TlsStorage.get(); //
Something bad happens, return uninitialized tls
I think it can be fault of missing extern before __declspec(dllexport)
boost::thread_specific_ptr<int> TlsStorage
in ThreadLoalStorage.cpp but when I add "extern" I have:
error LNK2001: unresolved external symbol "__declspec(dllimport) class
boost::thread_specific_ptr<int> threads::TlsStorage"
(__imp_?TlsStorage@threads@tlx@@3V?$thread_specific_ptr@H@boost@@A)
in compiling process. Maybe it's some issue with mangling ?