How to avoid stdafx and other header files

1.2k Views Asked by At

When creating a new C++ Windows Application in Visual Studio 2017, I am always given an stdafx.cpp file, as well as stdafx.h and targetver.h files. I am taking an Intro Programming class and the instructor thoroughly disapproves of these files being included in our projects. I am using a Mac with BootCamp to run this compiler properly, and I am able to write my code and run it fine - but I need to get rid of these extraneous files that are included with my project.

My professor's suggestion was to instead create an Empty Project when initially making the project, but this must leave out some type of necessary libraries/headers because my same code will misbehave with functions like "cout". (builds fine).

Put simply, how can I create a new project that is empty besides my cpp file, and behaves as normal?

2

There are 2 best solutions below

0
On

when you create a project with visual studio ,you'll have the option "use pre compiled headers" which you can disable !

NB Just discovered that the new update (15.3.5) of vs2017 has changed the creation of projects a little and seems to offer this only when choosing Windows desktop wizard !

0
On

You can create a new project and disable use of of precompiled headers and please also select Empty Project while creating. If you don't intend to create a new project file, you can do this in the existing project file.To do this, do the following -

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.