出现如下错误:
fatal error C1010: unexpected end of file while looking for precompiled header directive
cannot open file .\Debug\wRtu_Member_Function.sbr: No such file or directory
代码如下:
//.h
class CwRtu_Member_Function
{
public:
/*保存系统运行时间*/
static int second;
static int minute;
static int hour;
static int day;
};
//.cpp
#include "wRtu_Member_Function.h"
int CwRtu_Member_Function::day=00;
int CwRtu_Member_Function::hour=00;
int CwRtu_Member_Function::minute=00;
int CwRtu_Member_Function::second=00;
#include "wRtu_Member_Function.h" 前面加上#inlcude "stdafx.h" ,如下:
//.cpp
#inlcude "stdafx.h"
#include "wRtu_Member_Function.h"
。。。
fatal error C1010: unexpected end of file while looking for precompiled
说明你用了预编译头但是在.cpp里没有include这个头
.cpp加
#include "stdafx.h"
使用预编译头的话stdafx.h一定要第一个被include.
也就是#include "stdafx.h"要放在其它头文件include之前。
如果不使用预编译头,在工程设置中c/c++项中把" XXXX stdafx XXXX"那一句删掉