c++ - ifstream _Read_s 发生了什么?

标签 c++ visual-studio-2010 visual-c++ stl

我正在将 Visual Studio 解决方案从 2005 版移植到 2010 版。

其中一个项目是使用 ifstream 的 native C++ 项目。

转换过程成功完成,但是当我尝试构建 native 项目时,编译器提示“_Read_s 不是 ifstream 的成员”。

_Read_s 发生了什么?

有编译器更改导致方法无法访问吗?

这是 visual studio 2005 正确构建的代码:

ifstream binfile(pathFileToRead, ios::in | ios::binary | ios::beg);

while (!binfile.eof())
{
    binfile._Read_s(fileBuffer, CACHE_SIZE, CACHE_SIZE);

    //Do something with fileBuffer
}

最佳答案

看起来非标准的 basic_istream::_Read_s() 只存在于 VS 2005 和 VS 2008 中。

您可能应该将其更改为使用标准的 basic_istream::read() 函数:

binfile.read(fileBuffer, CACHE_SIZE);

关于c++ - ifstream _Read_s 发生了什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22246616/

相关文章:

c++ - 使用 C API 的奇怪的 lua 推送/弹出行为

c++ - 如何安全释放构造函数分配的资源?

c# - 配置系统初始化失败

c++ - 在 DLL 客户端中使用 dllimport 时出错

c++ - 如何推断迭代器模板类型或其模板的嵌套类型?

c++ - 如何使用 SSE(1,2,3,4) 优化?

c++ - vector.back() 抛出 "offset out of range"错误

c++ - "Access violation writing location"与 file.getline? (仅在发布版本中)

c++ - 无法在 MSVC10 中使用 SFINAE、类型特征和 static_assert

c++ - VC++ wcscpy_s 在 "Buffer is too small"上随机断言