c++ - 迁移工作模块时 Boost "is_virtual_base_of"编译错误

标签 c++ serialization boost

我一直在使用 boost 序列化,我开发了一个完整的模块来将类存储在持久性存储中,但是当我尝试将我的模块迁移到其他项目时,我遇到了一些我从未见过的错误,而且我没有找到任何相关的错误网上资料。

我得到的错误是:

In file included from support.../boost_1_44/boost/serialization/void_cast.hpp:29,
                 from support.../boost_1_44/boost/archive/detail/oserializer.hpp:57,
                 from support.../boost_1_44/boost/archive/detail/interface_oarchive.hpp:23,
                 from support.../boost_1_44/boost/archive/detail/common_oarchive.hpp:22,
                 from support.../boost_1_44/boost/archive/basic_binary_oarchive.hpp:34,
                 from support.../boost_1_44/boost/archive/binary_oarchive_impl.hpp:23,
                 from support.../boost_1_44/boost/archive/binary_oarchive.hpp:21,
                 from .../ps_proxy.h:54,

support.../boost_1_44/boost/type_traits/is_virtual_base_of.hpp:57:10: error: macro "X" requires 2 arguments, but only 1 given
support.../boost_1_44/boost/type_traits/is_virtual_base_of.hpp:58:18: error: macro "X" requires 2 arguments, but only 1 given
support.../boost_1_44/boost/type_traits/is_virtual_base_of.hpp:60:11: error: macro "X" requires 2 arguments, but only 1 given
support.../boost_1_44/boost/type_traits/is_virtual_base_of.hpp:57: error: declaration does not declare anything
support.../boost_1_44/boost/type_traits/is_virtual_base_of.hpp:58: error: declaration does not declare anything
support.../boost_1_44/boost/type_traits/is_virtual_base_of.hpp:60: error: declaration of '~boost::detail::is_virtual_base_of_impl<Base, Derived, mpl_::bool_<true> >::X' as non-function
support.../boost_1_44/boost/type_traits/is_virtual_base_of.hpp:60: error: expected ';' before 'throw'

我希望有人能给我一些提示,说明为什么会发生这种情况以及为什么它在一个模块上正常工作以及当我迁移它(应该是透明迁移)时它会抛出这些错误。

谢谢!

最佳答案

  1. boost::is_virtual_base_of<>用于实现 Boost.Serialization 的某处。
  2. 在 Boost 1.44 中,boost::is_virtual_base_of<>使用名为 X 的类型和 Y作为实现细节。
  3. 在您的其他项目中的某处有一个名为 X 的宏定义,打破X boost::is_virtual_base_of<> 的实现中使用的类型.

很明显X是一个糟糕的宏名称——如果它是你的,那么找到一个更好的名称,如果不是,那么给定义它的任何库的作者发电子邮件并提示(然后 #undef 它在包括任何 Boost 头文件之前)。

FWIW,这显然是一个足够普遍的问题,在 Boost 1.47 类型中命名为 boost_type_traits_internal_struct_Xboost_type_traits_internal_struct_Y被用来代替 XY ,因此升级到更新版本的 Boost 是解决您的症状的另一种方法。

关于c++ - 迁移工作模块时 Boost "is_virtual_base_of"编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7654928/

相关文章:

c# - 如何在没有第三方库的情况下序列化对象+压缩然后解压+反序列化?

c++ - Boost 单元测试编译通过 Eclipse 失败

c++ 运算符重载 += 有效但 << 无效

c# - 使用 NewtonSoft 将 JSON 对象反序列化为 .Net 对象

c++ - Winsock recv hooking with Detours

c# - 以人类可读的文本格式序列化

c++ - 在共享内存中复制 char* boost

c++ - 如何构建 boost 静态库?

c++ - 在 OpenCV 中结合仿射变换的内置函数?

c++ - 如何将静态方法添加到 QInputDialog 以返回自定义数据?