我一直在进行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'
我希望有人能给我一些提示,说明为什么会发生这种情况,以及为什么它可以在一个模块上正常工作,并且在我进行迁移(假定是透明迁移)时会引发这些错误。
谢谢!
最佳答案
boost::is_virtual_base_of<>
在Boost.Serialization的实现中使用。 boost::is_virtual_base_of<>
使用名为X
和Y
的类型作为实现详细信息。 X
的宏,它破坏了X
实现中使用的boost::is_virtual_base_of<>
类型。 显然
X
是一个糟糕的宏名称-如果是您自己的宏名称,然后找到一个更好的名称,如果不是,则通过电子邮件将定义了该库的作者发送给电子邮件并投诉(然后在添加任何Boost头之前,先#undef
)。FWIW,这显然是一个足够普遍的问题,在Boost 1.47中使用名为
boost_type_traits_internal_struct_X
和boost_type_traits_internal_struct_Y
的类型而不是X
和Y
,因此升级到最新版本的Boost是解决症状的另一种方法。