我正在将 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/