问题描述
我正在尝试用 C++ 编译一个简单的 VS 程序作为类的分配.我们只包含
并且我不断收到此错误:
I am trying to compile a simple VS program in C++ as an assignment for class. We only ever include <iostream>
and I keep getting this error:
1>Assignment.cpp(15):致命错误 C1010:在查找预编译头时意外的文件结尾.您是否忘记将 '#include "StdAfx.h"'
添加到您的源代码中?
1>Assignment.cpp(15): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add
'#include "StdAfx.h"'
to your source?
我的程序真的这么小...
My program is literally this small...
#include <iostream>
using namespace std;
int main()
{
unsigned int day = 30;
cout << "My Name is John Doe" << endl;
cout << "My Major is CS" << endl;
cout << "I was born on day " << day << endl;
return 0;
}
我刚刚安装了 Visual Studio Express 2010.我真的很想启动一个空项目,而不是安装所有这些预定义的文件,我认为这会让它变得更容易,但我在创建项目时从来没有得到这个选项.大家有什么建议吗?
I just installed Visual Studio Express 2010. Really I would love to start an empty project instead of installing with all these files predefined, I think it would make it a lot easier but I never get that option when creating a project. Anybody have any suggestions?
推荐答案
您始终可以在项目设置中禁用预编译头文件.
You can always disable the use of pre-compiled headers in the project settings.
VS 2010 的说明(对于其他版本的 VS 应该类似):
Instructions for VS 2010 (should be similar for other versions of VS):
选择您的项目,使用Project -> Properties"菜单并转到Configuration Properties -> C/C++ -> Precompiled Headers"部分,然后将Precompiled Header"设置更改为Not Using Precompiled Headers"选项.
Select your project, use the "Project -> Properties" menu and go to the "Configuration Properties -> C/C++ -> Precompiled Headers" section, then change the "Precompiled Header" setting to "Not Using Precompiled Headers" option.
<小时>
如果您只想为简单的 C++ 命令行程序(例如在介绍性 C++ 编程类中开发的程序)设置最小的 Visual Studio 项目,您可以创建一个 空 C++ 项目.
这篇关于如何避免预编译头文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!