Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid precompiled headers

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): 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; } 

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?

like image 724
Howdy_McGee Avatar asked Aug 31 '11 18:08

Howdy_McGee


People also ask

Why do I get precompiled headers?

You can precompile both C and C++ programs. In C++ programming, it's common practice to separate class interface information into header files. These header files can later be included in programs that use the class. By precompiling these headers, you can reduce the time a program takes to compile.

Do I need precompiled headers?

Usage of precompiled headers may significantly reduce compilation time, especially when applied to large header files, header files that include many other header files, or header files that are included in many translation units.

How do you make a precompiled header?

Configure Visual Studio to create precompiled headerschoose "All Configurations", then go to C/C++ -> Precompiled Headers, choose "Create Precompiled Header", make sure stdafx. h is the header file to use, and leave the rest to the default value.


1 Answers

You can always disable the use of pre-compiled headers in the project settings.

Instructions for VS 2010 (should be similar for other versions of VS):

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.


If you are only trying to setup a minimal Visual Studio project for simple C++ command-line programs (such as those developed in introductory C++ programming classes), you can create an empty C++ project.

like image 150
André Caron Avatar answered Sep 22 '22 06:09

André Caron