0

我们正在使用 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();
}

有什么帮助吗?

4

1 回答 1

0

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

于 2013-04-18T13:53:15.763 回答