Precompiled header
In computer programming, a precompiled header is a (C or C++) header file that is compiled into an intermediate form that is faster to process for the compiler. Usage of precompiled headers may significantly reduce compilation time, especially when applied to large header files, header files that include many other header files, or header files that are included in many translation units.
GCH
gcc-3.4 버전 이후부터 PCH 기능을 지원한다. PCH의 기본 개념은 많은 소스 파일에서 공통적으로 참조하는 헤더 파일들을(하나로 묶어) 미리 처리하여 컴파일 시간을 단축시키고자 하는 것이다.
C++의 경우:
C의 경우:
위와 같이 컴파일을 하면 꽤 큰 용량의 stdafx.h.gch
파일이 생긴다. 이 파일이 Pre-Compiled header 이다. Pre-Compiled header 를 쓰기 위해서는 원하는 곳에 #include "stdafx.h"
를 추가하는 것으로 끝난다. 즉 stdafx.h
파일이 있는 곳에 stdafx.h.gch
가 있으면 gch 를 먼저 확인한다.
See also
- Prefix header
- GCC
- GCH
- GCC:DependencyHeaderFiles: 종속성 파일들 목록.
Favorite site
- Wikipedia (en) Precompiled Headers에 대한 설명
- wxWiki - Precompiled Headers 1
- PCH(Pre-Compiled Header) 사용하기 2
- GCC Precompiled header 사용방법