尝试访问 dynamic_bitset 中的私有成员
Attempt to access private member in dynamic_bitset
我正在使用 Visual Studio 2017 构建 LucenePlusPlus,后者又使用 boost/dynamic_bitset.
LucenePlusPlus中的如下代码
const uint64_t* BitSet::getBits() {
return bitSet.empty() ? NULL : static_cast<const uint64_t*>(&bitSet.m_bits[0]);
}
生成以下致命编译器错误:
1>g:\luceneplusplus\src\core\util\bitset.cpp(20): error C2248: 'boost::dynamic_bitset<uint64_t,std::allocator<Block>>::m_bits': cannot access private member declared in class 'boost::dynamic_bitset<uint64_t,std::allocator<Block>>'
1> with
1> [
1> Block=uint64_t
1> ]
建议?
我已经追踪到我的 boost 1_75_0 的代码,我看到它有一个定义来有条件地保留对朋友的访问:
#if defined(BOOST_DYNAMIC_BITSET_DONT_USE_FRIENDS)
#define BOOST_DYNAMIC_BITSET_PRIVATE public
#else
#define BOOST_DYNAMIC_BITSET_PRIVATE private
#endif
因此看起来您应该能够将 -DBOOST_DYNAMIC_BITSET_DONT_USE_FRIENDS
添加到编译器定义中以解决此问题。
In fact, my LucenePlusPlus tree already contains it in
include/config_h/Config.h.in line 107:
#define BOOST_DYNAMIC_BITSET_DONT_USE_FRIENDS
Previously ("rebuilt cmake buildsystem") this apparently
came from include/Config.h.cmake, where it was always present, unconditionally all the way since 2010:
你能做什么?
也许您没有包括包含配置的必需 header?还要检查任何干扰预编译 header 设置。
如果您在包含 LucenePlusPlus header 之前先包含 boost/dynamic_bitset.hpp
,那么您将 运行 使用错误的配置。
This is especially bad if you don't detect it because that would violate the ODR rule
我正在使用 Visual Studio 2017 构建 LucenePlusPlus,后者又使用 boost/dynamic_bitset.
LucenePlusPlus中的如下代码
const uint64_t* BitSet::getBits() {
return bitSet.empty() ? NULL : static_cast<const uint64_t*>(&bitSet.m_bits[0]);
}
生成以下致命编译器错误:
1>g:\luceneplusplus\src\core\util\bitset.cpp(20): error C2248: 'boost::dynamic_bitset<uint64_t,std::allocator<Block>>::m_bits': cannot access private member declared in class 'boost::dynamic_bitset<uint64_t,std::allocator<Block>>'
1> with
1> [
1> Block=uint64_t
1> ]
建议?
我已经追踪到我的 boost 1_75_0 的代码,我看到它有一个定义来有条件地保留对朋友的访问:
#if defined(BOOST_DYNAMIC_BITSET_DONT_USE_FRIENDS)
#define BOOST_DYNAMIC_BITSET_PRIVATE public
#else
#define BOOST_DYNAMIC_BITSET_PRIVATE private
#endif
因此看起来您应该能够将 -DBOOST_DYNAMIC_BITSET_DONT_USE_FRIENDS
添加到编译器定义中以解决此问题。
In fact, my LucenePlusPlus tree already contains it in include/config_h/Config.h.in line 107:
#define BOOST_DYNAMIC_BITSET_DONT_USE_FRIENDS
Previously ("rebuilt cmake buildsystem") this apparently came from include/Config.h.cmake, where it was always present, unconditionally all the way since 2010:
你能做什么?
也许您没有包括包含配置的必需 header?还要检查任何干扰预编译 header 设置。
如果您在包含 LucenePlusPlus header 之前先包含 boost/dynamic_bitset.hpp
,那么您将 运行 使用错误的配置。
This is especially bad if you don't detect it because that would violate the ODR rule