-3

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?

18
  • 3
    Your professor is right. Make an empty project, then create a source file manually. It's easier than changing all the settings to remove precompiled headers Commented Sep 20, 2017 at 21:50
  • 1
    @tadman not if you're trying to compile the same code on a different compiler Commented Sep 20, 2017 at 21:50
  • 2
    Precompiled headers can decrease compilation times significantly, but it strongly depends on what you put in them and how you configure them. Done wrong, it's easy to increase compilation times significantly. For clean portability, it can be a better idea to use CMake and Cotire and never manually have a #include "stdafx.h". Commented Sep 20, 2017 at 21:54
  • 2
    @frejil You just need to figure out what is wrong with out program, maybe debug it. Precompiled headers have nothing to do with it. Commented Sep 20, 2017 at 22:03
  • 1
    cout << "enter height" << cin won't even compile, there is no << operator for output stream that takes input stream. Commented Sep 20, 2017 at 22:08

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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 !

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.