C++builder使用boost::thread

mac2022-06-30  25

1 #define BOOST_THREAD_USE_LIB 2 extern "C" 3 { 4 namespace boost 5 { 6 void tss_cleanup_implemented( void ) 7 { 8 /* 9 This function's sole purpose is to cause a link error in cases where 10 automatic tss cleanup is not implemented by Boost.Threads as a 11 reminder that user code is responsible for calling the necessary 12 functions at the appropriate times (and for implementing an a 13 tss_cleanup_implemented() function to eliminate the linker's 14 missing symbol error). 15 16 If Boost.Threads later implements automatic tss cleanup in cases 17 where it currently doesn't (which is the plan), the duplicate 18 symbol error will warn the user that their custom solution is no 19 longer needed and can be removed.*/ 20 } 21 } 22 } 23 #include <boost/thread.hpp> View Code

https://stackoverflow.com/questions/16443989/warnings-when-compiling-boost-libraries-in-c-builder/16448842#16448842

https://stackoverflow.com/questions/42855278/on-which-platforms-does-thread-specific-pointer-work-without-boostthread/42857031#42857031

POSIX threads (pthreads) provide interface for cleaning up thread-local storage, so this remark does not refer to any platforms correctly supporting pthreads.

On Windows there is no native API for TLS cleanup, so the library has to resort to various hacks to implement this. From the source (see here for the case when Boost.Thread is built as a dll, and herefor when it is a static library) you can see that MSVC and MinGW/MinGW-w64 are supported. The dll version is fairly portable, so the cleanup implementation may be missing if you use some exotic compiler on Windows and Boost.Thread is built as a static library.

Boost.Thread provides an indication mechanism for the case when user is required to provide TLS cleanup implementation. The application won't link because of a missing function boost::tss_cleanup_implemented. When such error appears, the user is expected to implement the TLS cleanup and this function (and empty implementation will suffice). When the cleanup is implemented by Boost.Thread, that function is defined by Boost.Thread as well.

转载于:https://www.cnblogs.com/PandaCPP/p/9685439.html

相关资源:垃圾分类数据集及代码
最新回复(0)