在c++ Builder中编译Boost库时的警告
Warnings when compiling Boost libraries in C++ Builder
当我试图在c++ Builder中包含<boost/thread.hpp>
时,我得到了警告。对于我包含它的每个单元,c++ Builder显示这两行:
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
已经尝试了一些方法,但是没有效果。
它编译正确,然而,它让我心烦意乱。为什么要显示这条信息?
#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);
}
,其中59是BOOST_THREAD_DECL
下面的{
, 69也是。看起来BOOST_THREAD_DECL
没有正确定义或定义错误,试图遵循Boost代码并不容易。
添加#在包含thread.hpp之前定义BOOST_THREAD_USE_LIB。
我测试的是:
#define BOOST_THREAD_USE_LIB
extern "C"
{
namespace boost
{
void tss_cleanup_implemented( void )
{
/*
This function's 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>
然后设置'Link with Dynamic RTL'和'Link with Runtime Packages'。
相关文章:
- 理解boost::asio-async_read在无需读取内容时的行为
- 警告处理为错误这里有什么问题
- 来自 Boost 的 JSON 解析器的警告 C4512 的解决方法
- 使用Boost :: black在boost :: variant中使用时,请警告编译器
- Boost序列化程序:除非使用虚拟类析构函数,否则将收到警告C4308
- boost::asio充满了警告
- jom.exe返回witd exitcode 2和许多Boost警告
- 为什么调用boost::split()会发出这么多警告
- 在 Boost 周围使用"#pragma warning"时的警告 C4503 包括
- 如何在x64上使用boost:gil:png_write_view避免此警告
- boost::lexical_cast编译时出现警告
- 抑制来自boost的警告
- 不能禁用由Boost库引起的警告
- Boost -在构建时关于解引用指针的警告
- 编译器警告在boost crc.hpp与Visual c++(错误C4244)
- boost::asio async_read_some async_read_until编译器警告
- 在c++ Builder中编译Boost库时的警告
- c++编译器在使用boost:: expression时给出了几页的警告
- 尝试初始化 wregex 对象时 boost 的 regex_traits_defaults.hpp 中的缩小转换警告
- 编译时带有boost::split的警告