我被这个编译器错误难住了,我一生都无法弄清楚发生了什么。整个错误对我来说没有多大意义,更奇怪的是,大部分代码都是从以前运行良好的项目中复制而来的。
错误和代码如下:
1>ClCompile:
1> main.cpp
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\fstream(1347): error C2248: 'std::basic_ios<_Elem,_Traits>::basic_ios' : cannot access private member declared in class 'std::basic_ios<_Elem,_Traits>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\ios(176) : see declaration of 'std::basic_ios<_Elem,_Traits>::basic_ios'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> This diagnostic occurred in the compiler generated function 'std::basic_fstream<_Elem,_Traits>::basic_fstream(const std::basic_fstream<_Elem,_Traits> &)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1>
1>Build FAILED.
这是main.cpp * 的非常小的代码:
#include <Mage/File/PlainText.h>
#include <cstdio>
int main(int argc, char** argv) {
Mage::FilePlainText file = Mage::FilePlainText("shadow_pcf_gaussian_fragment.glsl");
printf("%s\n", file.content().c_str());
while (true) { }
return 0;
}
和代码file.content():
Mage::String FilePlainText::content() {
Mage::String src;
try {
open();
// We allocate enough memory to copy the entire content to memory.
mHandle.seekg(0, std::ios::end);
src.reserve(mHandle.tellg());
// Set pointer to 0 and copy to memory.
mHandle.seekg(0, std::ios::beg);
src.assign((std::istreambuf_iterator<char>(mHandle)),
std::istreambuf_iterator<char>());
close();
} catch (Mage::Exception& e) {
throw e;
}
return src;
}
我的猜测是它与此有关。