Visual C++ Express 2010 突然不接受#includes
我正在使用一个 API,它已 #define
编辑了所有包含文件。我正在使用 Visual C++ 2010 Express 进行开发,到目前为止一切正常。
我正在向项目添加一个新的 cpp 文件,但不小心添加了一个“Windows 窗体”。 VC 警告我,我的项目目前没有使用 CLR,我真的想这样做吗?我单击“否”,然后按预期添加文件。然而,在那之后,我的项目不再编译。
代码基本上如下所示:
api_header.h:
#define DEFINED_HEADER_NAME "path/to/header/file.h"
stdhpf.h:
#include DEFINED_HEADER_NAME
正如我所说,在很长一段时间内工作得很好。现在我明白了:
错误 C2006:
'#include'
:需要一个文件名,找到'identifier'
致命错误 C1083:无法打开包含文件:''
:没有这样的文件或目录
是什么原因导致的?我发现一些帖子说这是因为打开了预编译头,但我检查了 Project Properties >配置属性> C/C++ / 预编译头
,并且它已关闭(我提到了设置路径,因为我是 VS 的新手,可能有不止一种方法可以做到这一点...)。
有什么想法吗?
I'm working with an API which has #define
ed all their include files. I'm developing in Visual C++ 2010 Express, and it's been working fine up till now.
I was adding a new cpp-file to the project, and accidentally added a "Windows Form" instead. VC warned me that my project was not using CLR at the moment, did I really want to? I clicked no, and added the file as intended. After that, however, my project no longer compiles.
The code looks basically like this:
api_header.h:
#define DEFINED_HEADER_NAME "path/to/header/file.h"
stdhpf.h:
#include DEFINED_HEADER_NAME
As I said, worked fine for a long time. Now I get this:
error C2006:
'#include'
: expected a filename, found'identifier'
fatal error C1083: Cannot open include file:''
: No such file or directory
What is causing this? I found some post that said it was because of having turned on precompiled headers, but I checked Project properties > Configuration properties > C/C++ / Precompiled headers
, and it's off (I mention the setting path since I'm new to VS, there might be more than one way to do it...).
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
几乎可以肯定,问题在于这两个语句的预处理顺序,而不是与无意中添加 Windows 窗体对象有关。
这篇知识库文章建议:
第二个错误似乎证实了这一点,因为它表明预处理器正在搜索名称为空的包含文件:
The problem almost certainly lies in the order in which the two statements are pre-processed, rather than having anything to do with inadvertently adding a Windows Form object.
This knowledge base article suggests:
The second error seems to confirm this, as it indicates the pre-processor is searching for an include file with an empty name:
包含文件的顺序已更改。也许 Visual Studio 在
#include "api_header.h"
之前的某个位置插入了#include "stdhpf.h"
。The order of your include files has changed. Perhaps Visual Studio inserted a
#include "stdhpf.h"
somewhere ahead of your#include "api_header.h"
.禁用预编译头。它应该有帮助。
Disable precompiled headers. It should helps.