我在与“头文件”和“源文件”相同的级别上添加了一个新的过滤器“外部”。外部过滤器还包含过滤器:include和lib。 Windows资源管理器视图中也有相同的目录结构。接下来,我将现有项添加到include和lib过滤器(分别为x.h和x.cpp)。 lib过滤器中的x.cpp具有以下内容:
#include "../../StdAfx.h"
StdAfx.h文件放置在“标题文件”中。 Visual Studio看到了包含,但是当我编译程序时,我得到了x.cpp的以下信息:
unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
这是怎么回事?奇怪的是,Visual Studio看到包含但后来不包含该文件。如何解决?
编辑:
x.cpp
#include "../../StdAfx.h"
#include "../include/myHeader.h"
void fun()
{}
答案 0 :(得分:-2)
尝试#include "stdafx.h"
或#include <stdafx.h>
,但不要添加。如果不需要标题,则下次创建项目时,请取消选择“预编译的标题”,然后单击“创建”按钮。