C++编译错误syntax error : identifier 'THIS_FILE' 解决方法

来源:互联网 发布:软件商业计划书范文 编辑:程序博客网 时间:2024/06/10 08:51
你到代码里搜索 THIS_FILE看是不是它定义在别的头文件前面了,如果是,把它们的头文件紧跟到Stdafx.h后面
我遇到过这问题,这样搞定的 

今天遇到个编译错误:..\vc98\include\new(35) : error C2061: syntax error : identifier 'THIS_FILE',我的某个.cpp中是这样写的:

#include "stdafx.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "myUtil.h"

百度了下说是#include顺序问题,要放到'THIS_FILE'定义之前,改成如下即可:

#include "stdafx.h"
#include "myUtil.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

0 0