与RTTI简单类的序列化加速关闭(-fno-RTTI) [英] Boost Serialization of simple class with RTTI turned Off (-fno-rtti)

查看:2113
本文介绍了与RTTI简单类的序列化加速关闭(-fno-RTTI)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图序列化使用升压序列化纯老的数据类型的简单类。但是,我唯一的要求是,我不能使用RTTI。因此,我用编译使用gcc 4.4.1 ARM Linux的最新的具有升压1.47库-fno-RTTI。

I am trying to serialize a simple class with Plain-old-Data types using boost serialization. However, my only requirement is that I cannot use RTTI. Thus I am compiling with -fno-rtti using gcc 4.4.1 for ARM Linux with latest Boost 1.47 library.

因此​​,这里是我的类:

So here is my class:

#include <boost/archive/xml_oarchive.hpp>
#include <boost/archive/xml_iarchive.hpp>

class libNemoMemento
{
    friend class boost::serialization::access;
    private:
        template<class Archive>
        void serialize(Archive & ar, const unsigned int version)
        {
            ar & BOOST_SERIALIZATION_NVP(temperature);
            ar & BOOST_SERIALIZATION_NVP(voltage);
            ar & BOOST_SERIALIZATION_NVP(bandwidth);
            ar & BOOST_SERIALIZATION_NVP(power);
        }
        int temperature;
        unsigned int voltage;
        unsigned int bandwidth;
        unsigned char power;
    public:
        libNemoMemento(void) {}
        virtual ~libNemoMemento(void) {}
};

我还没有落实的实际保存和加载功能,但(他们似乎从看Boost文档是pretty简单),但我已经收到以下编译器错误:

I haven't even implemented the actual save and load functions yet (they seem to be pretty straightforward from looking at the Boost documentation) but I am already getting the following compiler errors:

In file included from /home/me/prebuild/third-party/boost/include/boost/serialization/detail/shared_ptr_132.hpp:29,
                 from /home/me/third-party/boost/include/boost/serialization/shared_ptr_132.hpp:35,
                 from /home/me/third-party/boost/include/boost/archive/shared_ptr_helper.hpp:29,
                 from /home/me/third-party/boost/include/boost/archive/xml_iarchive.hpp:133,
                 from serialize_test.h:21,
                 from serialize_test.cpp:15:
/home/me/third-party/boost/include/boost/serialization/detail/shared_count_132.hpp: In member function 'virtual void* boost_132::detail::sp_counted_base_impl<P, D>::get_deleter(const std::type_info&)':
/home/me/third-party/boost/include/boost/serialization/detail/shared_count_132.hpp:274: error: cannot use typeid with -fno-rtti
In file included from /home/me/prebuild/third-party/boost/include/boost/serialization/shared_ptr_132.hpp:35,
                 from /home/me/prebuild/third-party/boost/include/boost/archive/shared_ptr_helper.hpp:29,
                 from /home/me/prebuild/third-party/boost/include/boost/archive/xml_iarchive.hpp:133,
                 from serialize_test.h:21,
                 from serialize_test.cpp:15:
/home/me/prebuild/third-party/boost/include/boost/serialization/detail/shared_ptr_132.hpp: In function 'D* boost_132::get_deleter(const boost_132::shared_ptr<U>&)':
/home/me/prebuild/third-party/boost/include/boost/serialization/detail/shared_ptr_132.hpp:465: error: cannot use typeid with -fno-rtti
make: *** [all] Error 1

所以..问题是,是否有可能使用序列化系列化提振这个简单的类不使用RTTI?我环顾四周,似乎像它可能会使用一些提振宏和机械(#包括LT&;升压/系列化/ extended_type_info_no_rtti.hpp>暗示这一点),但我是一个新的提高用户和pretty无能,如何进行。

So.. the question is, is it possible to serialize this simple class using boost serialization without using RTTI?? I have looked around and it seems like it may be possible using some boost macros and machinery (#include < boost/serialization/extended_type_info_no_rtti.hpp > alludes to this) but I am a new Boost user and pretty clueless as to how to proceed.

PS:如果我删除了-fno-RTTI我的code编译罚款

PS: My code compiles fine if I remove -fno-rtti.

推荐答案

在这个看看:

http://boost.2283326.n4.nabble.com/boost-serialization-and-RTTI-td2566883.html

这篇关于与RTTI简单类的序列化加速关闭(-fno-RTTI)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆