C++ - Precompile header file
来源:互联网 发布:北电网络被谁收购 编辑:程序博客网 时间:2024/05/22 18:04
缘起
In the C and C++ programming languages, aheader file is afile whose text may be automatically included in anothersource file by theC preprocessor, usually specified by the use ofcompiler directives in the source file.
Header files can sometimes contain a very large amount of source code (for instance, the header fileswindows.h
and Cocoa/Cocoa.h
onMicrosoft Windows and Mac OS X, respectively).
To reduce compilation times some compilers allow header files to be precompiled 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 extensions.pch or .gch.
Implementation in Windows - stdafx.h
stdafx.h is a file, generated by Microsoft Visual Studio IDE wizards, that describes both standard system and project specificinclude files that are used frequently but hardly ever change.
Compatible compilers (for example, Visual C++ 6.0 and newer) will pre-compile 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 theMicrosoft Foundation Classes (MFC). Optionally, Visual Studio projects may avoid pre-compiled headers, as well as they may specify an alternative name (thoughstdafx.h is used by default).
A common problem relevent
When compiling with Microsoft Visual C++, you get the following error: “c:\vcprojects\test.cpp(263) :fatal error C1010: unexpected end of file while looking for precompiled header directive”Answer : This error occurs when the Microsoft Visual C++ compiler is set to use precompiled headers but one of your C++ code files does not include the stdafx header as the first line. To fix this problem, simply locate the file producing the error (in the above error, test.cpp is the culprit), and add the following line at the very top of the file:
1
#include "stdafx.h"
Alternatively, you can turn off precompiled headers.
参考:
PCH Files in the Build Process: http://msdn.microsoft.com/en-us/library/hd8sctab%28v=vs.80%29.aspx
- C++ - Precompile header file
- Precompile Prefix Header
- C Include Header file
- Xcode Precompile Prefix Header浅析
- Xcode Precompile Prefix Header简析
- Xcode Precompile Prefix Header浅析
- Xcode Precompile Prefix Header浅析
- Xcode Precompile Prefix Header浅析
- Xcode Precompile Prefix Header浅析
- C/C++ header file lists
- Xcode6 找回消失的 Precompile Prefix Header
- Xcode6添加pch(Precompile Prefix Header)文件
- precompile
- file header
- 如何在Xcode6中添加pch(Precompile Prefix Header)
- 如何在Xcode6中添加pch(Precompile Prefix Header)
- iOS如何在Xcode7中手动添加Precompile Prefix Header?
- javah命令(C Header and Stub File Generator)
- Misc(网络+组成原理)
- dfd
- hdu--2521 反素素(题目具有迷惑性)
- C#中根据类的名称字符串创建类的实例
- 快暑假了
- C++ - Precompile header file
- 细看代码在内存中如何存储
- aspnet的menu控件在ie8中不能正常显示
- P4 tips
- 快暑假了
- 字符集之间转换(UTF-8,UNICODE,Gb2312)
- 二叉查找树书中实现
- INSERT触发器简单工作原理举例
- 数组元素的指针和数组的指针