Precompiled Header
2012-02-23 10:38
225 查看
开始学C++……
错误 2
error C1010: 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include "StdAfx.h"”?
于是有几个问题:
为什么VS需要查找预编译头?
添加一个头文件有啥用?而且stdafx.h里边没啥东西……
先贴上吧,以后再总结。下面来自维基百科
In the C and C++ programming
languages, a header file is a file whose text may be automatically included in another source
file by the C preprocessor by the use of a compiler
directive in the source file.
Header files can sometimes contain very large amounts of source code (for instance, the header files
Windows and Mac OS X, respectively). This is especially true with the advent of large 'header' libraries that
make extensive use of templates, like the Eigen
math library and the Boost (C++ libraries). They are written almost entirely
as header files that the user #includes, rather than being linked at runtime. Thus each time the user compiles their program, they are essentially recompiling numerous header libraries as well that would ordinarily have been precompiled into shared objects
or dynamic link libraries.
To reduce compilation times, some compilers allow header files to be compiled into a form that is faster for the compiler to process. This intermediate form is known as aprecompiled header, and is commonly held in a file named with the extension .pch or
similar, such as .gch under the GNU
Compiler Collection.
A related feature is the prefix header, which is a file that is automatically included by the compiler
without requiring the use of any compiler directives. Prefix headers are commonly precompiled, but not all precompiled headers are prefix headers.
stdafx.h is a file, generated by Microsoft Visual Studio IDE wizards,
that describes both standard system and project specific include files that are used frequently but hardly
ever change.
Compatible compilers (for example, Visual C++ 6.0 and newer) will precompile
this file to reduce overall compile times. Visual C++ will not compile anything before the
unchecked (by default); it assumes all code in the source up to and including that line is already compiled.
The AFX in stdafx.h stands for Application Framework eXtensions. AFX was the original abbreviation for the Microsoft
Foundation Classes (MFC). While the name stdafx.h is used by default, projects may specify an alternative name.
看来这个stdafx.h是起了一个标识的作用,不具有通常.h文件的功能。
重点在于: Visual C++ will not compile anything before the
unchecked (by default); it assumes all code in the source up to and including that line is already compiled.
这个precompiled header是为了减少编译时由于#include带来的不必要的编译的负担。
错误 2
error C1010: 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include "StdAfx.h"”?
于是有几个问题:
为什么VS需要查找预编译头?
添加一个头文件有啥用?而且stdafx.h里边没啥东西……
先贴上吧,以后再总结。下面来自维基百科
In the C and C++ programming
languages, a header file is a file whose text may be automatically included in another source
file by the C preprocessor by the use of a compiler
directive in the source file.
Header files can sometimes contain very large amounts of source code (for instance, the header files
windows.hand
Cocoa/Cocoa.hon Microsoft
Windows and Mac OS X, respectively). This is especially true with the advent of large 'header' libraries that
make extensive use of templates, like the Eigen
math library and the Boost (C++ libraries). They are written almost entirely
as header files that the user #includes, rather than being linked at runtime. Thus each time the user compiles their program, they are essentially recompiling numerous header libraries as well that would ordinarily have been precompiled into shared objects
or dynamic link libraries.
To reduce compilation times, some compilers allow header files to be compiled into a form that is faster for the compiler to process. This intermediate form is known as aprecompiled header, and is commonly held in a file named with the extension .pch or
similar, such as .gch under the GNU
Compiler Collection.
A related feature is the prefix header, which is a file that is automatically included by the compiler
without requiring the use of any compiler directives. Prefix headers are commonly precompiled, but not all precompiled headers are prefix headers.
[edit]
stdafx.h
stdafx.h is a file, generated by Microsoft Visual Studio IDE wizards,that describes both standard system and project specific include files that are used frequently but hardly
ever change.
Compatible compilers (for example, Visual C++ 6.0 and newer) will precompile
this file to reduce overall compile times. Visual C++ will not compile anything before the
#include "stdafx.h"in the source file, unless the compile option
/Yu'stdafx.h'is
unchecked (by default); it assumes all code in the source up to and including that line is already compiled.
The AFX in stdafx.h stands for Application Framework eXtensions. AFX was the original abbreviation for the Microsoft
Foundation Classes (MFC). While the name stdafx.h is used by default, projects may specify an alternative name.
看来这个stdafx.h是起了一个标识的作用,不具有通常.h文件的功能。
重点在于: Visual C++ will not compile anything before the
#include "stdafx.h"in the source file, unless the compile option
/Yu'stdafx.h'is
unchecked (by default); it assumes all code in the source up to and including that line is already compiled.
这个precompiled header是为了减少编译时由于#include带来的不必要的编译的负担。
相关文章推荐
- fatal error C1010: unexpected end of file while looking for precompiled header directive
- 如何解决…has been modified since the precompiled header… was built的问题
- not the pdb file that was used when this precompiled header wascreated
- fatal error C1083: Cannot open precompiled header file: 'Debug/Example_VC1.pch': No such file or dir
- VC 6.0:fatal error C1083: Cannot open precompiled header file:
- fatal error C1083: Cannot open precompiled header file: 'Debug/ex1_2.pch': No such file or directory
- has been modified since the precompiled header的几种解决方案
- C++:unexpected end of file while looking for precompiled header directive
- fatal error C1010: unexpected end of file while looking for precompiled header directive
- Cannot open precompiled header file: 'Debug/.pch': No such file or directory
- Cannot open precompiled header file: 'Release/BeastScaner.pch' 解决办法
- fatal error C1083: Cannot open precompiled header file: 'Debug/2_1.pch': No such file or directory
- VS2008 编译出错 fatal error C1859: unexpected precompiled header error, simply rerunning the compiler might fix this problem
- Cannot open precompiled header file: 'Debug/****.pch': No such file or directory
- Precompiled Header和Incredibuild的恩怨
- Cannot open precompiled header file: 'Debug/text.pch': No such file or director
- has been modified since the precompiled header was built IOS开发
- 采用MingW编译OPENCV,出现recipe for target xxx/can't create precompiled header错误解决方法
- VC++6.0编译时出现fatal error C1010: unexpected end of file while looking for precompiled header directiv
- Cannot open precompiled header file: 'Debug/****.pch': No such file or directory