Error Description: fatal error C1010: unexpected end of file encountered when looking for precompiled header. Did you forget to add "#include" stdafx.h "" the source? (Rpm)

Error Analysis:

    This error occurs because the compiler is looking for precompiled header files instructions (default #include "stdafx.h"), the file is not expected to be completed. We did not find precompiled header file information indicating the "stdafx.h".
    ( Because each cpp file attribute is the default project using precompiled header (/ YU) of (chosen to use, it is necessary in the source file explicitly write #include), but did not add third-party file # include "stdafx.h" precompiled header instructions , until the end of the compiler did not find it in this cpp file)
    I have this problem in my way by adding a file, add an existing a big lump into the MFC .h and .cpp files. The .h and .cpp files belong to the scope of the code stream of open standard C ++, MFC-free relationship with deeper.

Solution:
A
1) In Solution Explorer, right-click on the corresponding .cpp file, click "Properties" (I: The first time that this play can cpp 555555)
2) in the left configuration properties, opening the "C / C ++", click "precompiled headers"
3) change the first line to the right of the "create / use precompiled headers" option from the "use precompiled header (/ Yu)" to "not using precompiled headers "
4) Note: each error of .cpp should change oh so hard to chant ~
II.
(not recommended)
1) Right-click the project in solution, click properties
2) in the configuration properties -> c / c ++ -> precompiled headers will "use precompiled header (/ YU)" to "NA precompiled header"
this approach will make every compilation process is very slow

Note:
1) looks like you can also include stdafx.h header file directly in the .cpp. But I did not try so modified, because do not want to undermine the standard of the source code ^ _ ^
2) VC feeling about identifying, compiling -_- lag in this area, perhaps because it was too strong, there is no thoughtful, actually need manually modify ~
3) Qt little miss the ......
 
 
supplementary information:
source: http: //blog.csdn.net/hotandhot/archive/2006/10/23/1346195.aspx
 
First, the concept:

1, pre-compiler: the compiler is the first to compile a file (called precompiled header file), and then save it to compile this result, after time if there are other sources of this document include "precompiled headers", then automatically extract information needs to be compiled from the results of this compilation.

2, pre-compiled results file (Precompiled header file): is used to save the file has been compiled symbol information (.PCH as a suffix)

3, generated pre-compiled results file (Create Precompiled header file): We say A source file by file B "to generate pre-compiled results file" refers to the compilation A time in which to save the compiler result B into a pre-compiled results file. Generally use the wizard, then, A file is "stdafx.cpp", B is a file "stdafx.h". stdafx.cpp in just one line statement:

#include “stdafx.h”

4, using precompiled headers (Using precompiled header): We say that a source file (a.cpp) by "stdafx.h" to use precompiled result means the time to compile a.cpp, if the first line a.cpp include statement #include "stdafx.h", then take a direct result of the result of pre-compiled files, no longer recompile "stdafx.h"

Second, the guide is how to do?

1, set the "stdafx.cpp" pre-compiler option is through "stdafx.h" file to "generate a pre-compiled results file."

2, pre-compiler option settings other source files by "stdafx.h" to "use precompiled headers"

Third, the use doctrine?

1, the relative stability of the header files (such as CRT (C runtime library), STL, fixed third party libraries) all written in the stdafx.h. (Whether stdafx.h depend on personal preference, but stdafx.h can use wizards and consistent)

2, all the source files of the first row (must be the first line) are added #include "stdafx.h".

3, that can not modify the source file (the code if the code is public, does not have permission to modify), set up his pre-compiler option is "do not use precompiled headers" . Note that the choice must not be "automatically generated precompiled header" because this will result stdafx.h flush (this is a question I do not know BUG or design, and. ^ _ ^.).

四、Q&A

Q, Why do not all use the "auto-generated precompiled header files"?

A, "auto-generated precompiled header files" and nothing needs no different, no qualitative increase compilation speed.

Add Q, manual a new source file to the project, similar errors often occur:

fatal error C1010: unexpected end of file while looking for precompiled header directive

A, because the wizard default setting is "using precompiled headers," but you add a new file and does not include "stdafx.h" in the first line. The solution is either modified to "do not use precompiled headers", or add a line #include "stdafx.h"

Q, plus stdafx.h and stdafx.cpp always think it is compiled and bound platform, not


----------------
Disclaimer: This article is the original article CSDN bloggers "ghevinn", and follow CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement. .
Original link: https: //blog.csdn.net/ghevinn/article/details/36629681

Guess you like

Origin www.cnblogs.com/Stephen-Qin/p/11704931.html