Warnings when compiling Boost libraries in C ++ Builder

I get warnings when I try to enable <boost/thread.hpp> in C ++ Builder. For each module I enable it, C ++ Builder shows these two lines:

 thread_heap_alloc.hpp(59): W8128 Can't import a function being defined thread_heap_alloc.hpp(69): W8128 Can't import a function being defined 

Already tried something, nothing worked.

It compiles correctly, however, it is nervous. Why is this message displayed?

Lines:

 #include <boost/config/abi_prefix.hpp> namespace boost { namespace detail { inline BOOST_THREAD_DECL void* allocate_raw_heap_memory(unsigned size) { void* const eap_memory=detail::win32::HeapAlloc(detail::win32::GetProcessHeap(),0,size); if(!heap_memory) { throw std::bad_alloc(); } return heap_memory; } inline BOOST_THREAD_DECL void free_raw_heap_memory(void* heap_memory) { BOOST_VERIFY(detail::win32::HeapFree(detail::win32::GetProcessHeap(),0,heap_memory)!=0); } 

where 59 is { below BOOST_THREAD_DECL , as is 69. It seems that BOOST_THREAD_DECL not defined correctly or incorrectly defined, trying to execute Boost code is not so simple.

This is Boost 1.39.

+4
source share
1 answer

add #define BOOST_THREAD_USE_LIB before including thread.hpp.

This is what I tested:

 #define BOOST_THREAD_USE_LIB extern "C" { namespace boost { void tss_cleanup_implemented( void ) { /* This function sole purpose is to cause a link error in cases where automatic tss cleanup is not implemented by Boost.Threads as a reminder that user code is responsible for calling the necessary functions at the appropriate times (and for implementing an a tss_cleanup_implemented() function to eliminate the linker's missing symbol error). If Boost.Threads later implements automatic tss cleanup in cases where it currently doesn't (which is the plan), the duplicate symbol error will warn the user that their custom solution is no longer needed and can be removed.*/ } } } #include <boost/thread.hpp> 

Then install "Link with Dynamic RTL" and "Link with Runtime Packages".

This makes a clean build and starts the thread correctly.

The blog currently does not work, but this link will be valid in the future (or will be edited to become valid, sorry, I wrote a blog entry for this: http://blog.marionette.ca/cross-platform-threading-for - c-builder-using-boostthread /

+7
source

Source: https://habr.com/ru/post/1479765/


All Articles