【问题标题】:boost serialization run-time error with strings in windows使用 Windows 中的字符串提升序列化运行时错误
【发布时间】:2013-04-17 15:22:04
【问题描述】:

我们正在使用 boost::serialization 测试一个非常简单的序列化代码。测试只是在文件中写入一个 std::string。

它编译正常,但问题是它在调用

test.exe 中 0x1004b370 (msvcr100d.dll) 0x000000000021647a 中未处理的异常:0xC0000005:0x000000000021647a 中的访问冲突

我们使用的是在 windows 7 64 位中使用 visualc++2010 编译的 boost 1.53 库。还尝试使用 Intel 12.1 64 位,但没有成功。

#include <fstream> 
#include <boost/serialization/string.hpp>
#include <boost/archive/text_oarchive.hpp> 

int main(int argc, char * argv[])
{
    std::string s = "HelloWorld!"; 

    std::ofstream file("archive.txt"); 
    boost::archive::text_oarchive oa(file); 

    oa << s;

    file.close();
}

有什么帮助吗?

【问题讨论】:

  • 编译参数?
  • boost 已使用下载文件夹中的以下行编译:bjam.exe variant=debug link=shared threading=multi runtime-link=shared --stagedir=./ --build-type=complete - -with-serialization address-model=64
  • 当你使用stringstream而不是ofstream时,你会遇到同样的崩溃吗?
  • 该代码在我的系统(linux,boost 1.44)上编译并运行良好,因此我要求编译标志。

标签: c++ visual-studio-2010 visual-c++ boost boost-serialization


【解决方案1】:

我们发现问题出在我们在项目中使用的预处理指令 _HAS_ITERATOR_DEBUGGING=0 上。使用时,fstream 不能正常工作。任何想法为什么?这是 fstream 中的错误(不太可能)吗?谢谢

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-03-23
    • 1970-01-01
    • 2015-07-22
    • 1970-01-01
    • 2016-12-24
    • 1970-01-01
    • 2023-03-14
    相关资源
    最近更新 更多