Jump to content
  • Advertisement
Sign in to follow this  
Eriond

Problems with boost::serialization

This topic is 5046 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I downloaded boost 1.32.0 today and built everything (I think). When I tried one of the samples from the serialization docs it didn't work very well.
#include <fstream>
#include <boost/archive/text_oarchive.hpp>

// had to add this, without I got loads of linker errors
// don't know if this is the right lib to link, there are quite many of them
#pragma comment(lib, "libboost_serialization-vc71-sgd-1_32.lib")

class gps_position
{
private:
    friend class boost::serialization::access;
    template<class Archive>
    void serialize(Archive & ar, const unsigned int version)
    {
        ar & degrees;
        ar & minutes;
        ar & seconds;
    }
    int degrees;
    int minutes;
    float seconds;
public:
    gps_position(){};
    gps_position(int d, int m, float s) :
        degrees(d), minutes(m), seconds(s)
    {}
};

int main()
{
    std::ofstream file("hmm");
    boost::archive::text_oarchive oa(file);
    gps_position g(35, 59, 24.567f);
    oa << g;
}
This crashes with a debug error. It's the last line that causes the crash.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!