How to avoid precompiled headers

前端 未结 4 1990
说谎
说谎 2020-11-27 04:19

I am trying to compile a simple VS program in C++ as an assignment for class. We only ever include and I keep getting this error:

相关标签:
4条回答
  • 2020-11-27 05:01

    You can create an empty project by selecting the "Empty Project" from the "General" group of Visual C++ projects (maybe that project template isn't included in Express?).

    To fix the problem in the project you already have, open the project properties and navigate to:

    Configuration Properties | C/C++ | Precompiled Headers
    

    And choose "Not using Precompiled Headers" for the "Precompiled Header" option.

    0 讨论(0)
  • 2020-11-27 05:24

    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.

    0 讨论(0)
  • 2020-11-27 05:25

    The .cpp file is configured to use precompiled header, therefore it must be included first (before iostream). For Visual Studio, it's name is usually "stdafx.h".

    If there are no stdafx* files in your project, you need to go to this file's options and set it as “Not using precompiled headers”.

    0 讨论(0)
  • 2020-11-27 05:25

    try to add #include "stdafx.h" before #include "iostream"

    0 讨论(0)
提交回复
热议问题