問題描述
我正在嘗試用 C++ 編譯一個(gè)簡單的 VS 程序作為類的分配.我們只包含
并且我不斷收到此錯(cuò)誤:
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):致命錯(cuò)誤 C1010:在查找預(yù)編譯頭時(shí)意外的文件結(jié)尾.您是否忘記將 '#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.我真的很想啟動(dòng)一個(gè)空項(xiàng)目,而不是安裝所有這些預(yù)定義的文件,我認(rèn)為這會(huì)讓它變得更容易,但我在創(chuàng)建項(xiàng)目時(shí)從來沒有得到這個(gè)選項(xiàng).大家有什么建議嗎?
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?
推薦答案
您始終可以在項(xiàng)目設(shè)置中禁用預(yù)編譯頭文件.
You can always disable the use of pre-compiled headers in the project settings.
VS 2010 的說明(對于其他版本的 VS 應(yīng)該類似):
Instructions for VS 2010 (should be similar for other versions of VS):
選擇您的項(xiàng)目,使用Project -> Properties"菜單并轉(zhuǎn)到Configuration Properties -> C/C++ -> Precompiled Headers"部分,然后將Precompiled Header"設(shè)置更改為Not Using Precompiled Headers"選項(xiàng).
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.
<小時(shí)>
如果您只想為簡單的 C++ 命令行程序(例如在介紹性 C++ 編程類中開發(fā)的程序)設(shè)置最小的 Visual Studio 項(xiàng)目,您可以創(chuàng)建一個(gè) 空 C++ 項(xiàng)目.
這篇關(guān)于如何避免預(yù)編譯頭文件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!