Jump to content
  • Advertisement
Sign in to follow this  
Eriond

Problems with boost::serialization

This topic is 5130 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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!