今天在学习detours的使用,在编译一个程序时提示了错误!
1>—— 已启动生成: 项目: Detours_test, 配置: Release Win32 ——
1>正在编译…
1>Detours MsgBox.cpp
1>.\Detours MsgBox.cpp(4) : fatal error C1083: 无法打开包括文件:“fstream.h”: No such file or directory
1>生成日志保存在“file://d:\MyProject\VC++就业培训宝典\第7章\复件 Detours\Release\BuildLog.htm”
1>Detours_test - 1 个错误,0 个警告
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========
fstream.h不存在,而且还是<>,调用系统的。前面几个detours的dll都编译成功了,纳闷了是查,于是就查了下MDSN。
https://msdn.microsoft.com/en-us/library/aa277521?query=
ofstream::ofstream
Visual Studio 6.0 //注意这里
ofstream();
ofstream( const char* szName, int nMode = ios::out, int nProt = filebuf::openprot );
ofstream( filedesc fd );
ofstream( filedesc fd, char* pch, int nLength );
Parameters
原来只有在VS2008中没有这个文件。不应该啊!应该是升级了。于是在VS2008离线的MSDN中搜索fstream,果然得到了答案。
A type basic_fstream specialized on char template parameters.
typedef basic_fstream
解决方法出来了,替换下
//#include <fstream.h> //VC6.0
#include <fstream>
using namespace std;
就顺利编译通过了。
小结:对于其它旧版本的源码编译出错,也可以使用这个方法。