<s>
In	O
computer	B-General_Concept
programming	I-General_Concept
,	O
a	O
precompiled	B-Language
header	I-Language
(	O
PCH	O
)	O
is	O
a	O
(	O
C	B-Language
or	O
C++	B-Language
)	O
header	B-Language
file	I-Language
that	O
is	O
compiled	B-Language
into	O
an	O
intermediate	B-Application
form	I-Application
that	O
is	O
faster	O
to	O
process	O
for	O
the	O
compiler	B-Language
.	O
</s>
<s>
Usage	O
of	O
precompiled	B-Language
headers	I-Language
may	O
significantly	O
reduce	O
compilation	B-Application
time	I-Application
,	O
especially	O
when	O
applied	O
to	O
large	O
header	B-Language
files	I-Language
,	O
header	B-Language
files	I-Language
that	O
include	O
many	O
other	O
header	B-Language
files	I-Language
,	O
or	O
header	B-Language
files	I-Language
that	O
are	O
included	B-Language
in	O
many	O
translation	B-Language
units	I-Language
.	O
</s>
<s>
In	O
the	O
C	B-Language
and	O
C++	B-Language
programming	I-Language
languages	I-Language
,	O
a	O
header	B-Language
file	I-Language
is	O
a	O
file	O
whose	O
text	O
may	O
be	O
automatically	O
included	B-Language
in	O
another	O
source	O
file	O
by	O
the	O
C	B-Language
preprocessor	I-Language
by	O
the	O
use	O
of	O
a	O
preprocessor	O
directive	O
in	O
the	O
source	O
file	O
.	O
</s>
<s>
Header	B-Language
files	I-Language
can	O
sometimes	O
contain	O
very	O
large	O
amounts	O
of	O
source	O
code	O
(	O
for	O
instance	O
,	O
the	O
header	B-Language
files	I-Language
windows.h	O
and	O
Cocoa/Cocoa.h	O
on	O
Microsoft	B-Application
Windows	I-Application
and	O
OS	B-Operating_System
X	I-Operating_System
,	O
respectively	O
)	O
.	O
</s>
<s>
This	O
is	O
especially	O
true	O
with	O
the	O
advent	O
of	O
large	O
"	O
header	O
"	O
libraries	O
that	O
make	O
extensive	O
use	O
of	O
templates	B-Application
,	O
like	O
the	O
Eigen	B-Library
math	I-Library
library	I-Library
and	O
Boost	B-Language
C++	I-Language
libraries	I-Language
.	O
</s>
<s>
They	O
are	O
written	O
almost	O
entirely	O
as	O
header	B-Language
files	I-Language
that	O
the	O
user	O
#includes	O
,	O
rather	O
than	O
being	O
linked	O
at	O
runtime	O
.	O
</s>
<s>
Thus	O
,	O
each	O
time	O
the	O
user	O
compiles	B-Language
their	O
program	O
,	O
the	O
user	O
is	O
essentially	O
recompiling	O
numerous	O
header	O
libraries	O
as	O
well	O
.	O
</s>
<s>
To	O
reduce	O
compilation	B-Language
times	O
,	O
some	O
compilers	B-Language
allow	O
header	B-Language
files	I-Language
to	O
be	O
compiled	B-Language
into	O
a	O
form	O
that	O
is	O
faster	O
for	O
the	O
compiler	B-Language
to	O
process	O
.	O
</s>
<s>
This	O
intermediate	B-Application
form	I-Application
is	O
known	O
as	O
a	O
precompiled	B-Language
header	I-Language
,	O
and	O
is	O
commonly	O
held	O
in	O
a	O
file	O
named	O
with	O
the	O
extension	O
.pch	O
or	O
similar	O
,	O
such	O
as	O
.gch	O
under	O
the	O
GNU	B-Application
Compiler	I-Application
Collection	I-Application
.	O
</s>
<s>
For	O
example	O
,	O
given	O
a	O
C++	B-Language
file	O
source.cpp	O
that	O
includes	O
header.hpp	O
:	O
</s>
<s>
When	O
compiling	B-Language
source.cpp	O
for	O
the	O
first	O
time	O
with	O
the	O
precompiled	B-Language
header	I-Language
feature	O
turned	O
on	O
,	O
the	O
compiler	B-Language
will	O
generate	O
a	O
precompiled	B-Language
header	I-Language
,	O
header.pch	O
.	O
</s>
<s>
The	O
next	O
time	O
,	O
if	O
the	O
timestamp	O
of	O
this	O
header	O
did	O
not	O
change	O
,	O
the	O
compiler	B-Language
can	O
skip	O
the	O
compilation	B-Language
phase	O
relating	O
to	O
header.hpp	O
and	O
instead	O
use	O
header.pch	O
directly	O
.	O
</s>
<s>
Microsoft	B-Application
Visual	I-Application
C++	I-Application
(	O
version	O
6.0	O
and	O
newer	O
)	O
can	O
precompile	O
any	O
code	O
,	O
not	O
just	O
headers	O
.	O
</s>
<s>
The	O
/Yu	O
option	O
,	O
subordinate	O
to	O
the	O
/Yc	O
option	O
if	O
used	O
together	O
,	O
causes	O
the	O
compiler	B-Language
to	O
make	O
use	O
of	O
already	O
precompiled	O
code	O
from	O
such	O
a	O
file	O
.	O
</s>
<s>
pch.h	O
(	O
named	O
stdafx.h	B-Language
before	O
Visual	B-Application
Studio	I-Application
2017	O
)	O
is	O
a	O
file	O
generated	O
by	O
the	O
Microsoft	B-Application
Visual	I-Application
Studio	I-Application
IDE	B-Application
wizard	O
,	O
that	O
describes	O
both	O
standard	O
system	O
and	O
project	O
specific	O
include	B-Language
files	I-Language
that	O
are	O
used	O
frequently	O
but	O
hardly	O
ever	O
change	O
.	O
</s>
<s>
The	O
afx	O
in	O
stdafx.h	B-Language
stands	O
for	O
application	B-Language
framework	I-Language
extensions	I-Language
.	O
</s>
<s>
AFX	O
was	O
the	O
original	O
abbreviation	O
for	O
the	O
Microsoft	B-Language
Foundation	I-Language
Classes	I-Language
(	O
MFC	O
)	O
.	O
</s>
<s>
While	O
the	O
name	O
stdafx.h	B-Language
was	O
used	O
by	O
default	O
in	O
MSVC	B-Application
projects	O
prior	O
to	O
version	O
2017	O
,	O
any	O
alternative	O
name	O
may	O
be	O
manually	O
specified	O
.	O
</s>
<s>
Compatible	O
compilers	B-Language
will	O
precompile	O
this	O
file	O
to	O
reduce	O
overall	O
compile	B-Application
times	I-Application
.	O
</s>
<s>
Visual	B-Application
C++	I-Application
will	O
not	O
compile	B-Language
anything	O
before	O
the	O
#include	O
"	O
pch.h	O
"	O
in	O
the	O
source	O
file	O
,	O
unless	O
the	O
compile	B-Language
option	O
/Yu	O
'	O
pch.h	O
'	O
is	O
unchecked	O
(	O
by	O
default	O
)	O
;	O
it	O
assumes	O
all	O
code	O
in	O
the	O
source	O
up	O
to	O
and	O
including	O
that	O
line	O
is	O
already	O
compiled	B-Language
.	O
</s>
<s>
Precompiled	B-Language
headers	I-Language
are	O
supported	O
in	O
GCC	B-Application
(	O
3.4	O
and	O
newer	O
)	O
.	O
</s>
<s>
GCC	B-Application
's	O
approach	O
is	O
similar	O
to	O
these	O
of	O
VC	O
and	O
compatible	O
compilers	B-Language
.	O
</s>
<s>
GCC	B-Application
saves	O
precompiled	O
versions	O
of	O
header	B-Language
files	I-Language
using	O
a	O
"	O
.gch	O
"	O
suffix	O
.	O
</s>
<s>
When	O
compiling	B-Language
a	O
source	O
file	O
,	O
the	O
compiler	B-Language
checks	O
whether	O
this	O
file	O
is	O
present	O
in	O
the	O
same	O
directory	O
and	O
uses	O
it	O
if	O
possible	O
.	O
</s>
<s>
GCC	B-Application
can	O
only	O
use	O
the	O
precompiled	O
version	O
if	O
the	O
same	O
compiler	B-Language
switches	O
are	O
set	O
as	O
when	O
the	O
header	O
was	O
compiled	B-Language
and	O
it	O
may	O
use	O
at	O
most	O
one	O
.	O
</s>
<s>
Further	O
,	O
only	O
preprocessor	O
instructions	O
may	O
be	O
placed	O
before	O
the	O
precompiled	B-Language
header	I-Language
(	O
because	O
it	O
must	O
be	O
directly	O
or	O
indirectly	O
included	B-Language
through	O
another	O
normal	O
header	O
,	O
before	O
any	O
compilable	O
code	O
)	O
.	O
</s>
<s>
GCC	B-Application
automatically	O
identifies	O
most	O
header	B-Language
files	I-Language
by	O
their	O
extension	O
.	O
</s>
<s>
because	O
of	O
non-standard	O
header	O
extensions	O
)	O
,	O
the	O
-x	O
switch	O
can	O
be	O
used	O
to	O
ensure	O
that	O
GCC	B-Application
treats	O
the	O
file	O
as	O
a	O
header	O
.	O
</s>
<s>
The	O
clang	B-Application
compiler	B-Language
added	O
support	O
for	O
PCH	O
in	O
Clang	B-Application
2.5	O
/	O
LLVM	B-Application
2.5	O
of	O
2009	O
.	O
</s>
<s>
The	O
compiler	B-Language
both	O
tokenizes	O
the	O
input	O
source	O
code	O
and	O
performs	O
syntactic	B-Language
and	O
semantic	O
analyses	O
of	O
headers	O
,	O
writing	O
out	O
the	O
compiler	B-Language
's	O
internal	O
generated	O
abstract	B-Data_Structure
syntax	I-Data_Structure
tree	I-Data_Structure
(	O
AST	O
)	O
and	O
symbol	B-Application
table	I-Application
to	O
a	O
precompiled	B-Language
header	I-Language
file	O
.	O
</s>
<s>
clang	B-Application
's	O
precompiled	B-Language
header	I-Language
scheme	O
,	O
with	O
some	O
improvements	O
such	O
as	O
the	O
ability	O
for	O
one	O
precompiled	B-Language
header	I-Language
to	O
reference	O
another	O
,	O
internally	O
used	O
,	O
precompiled	B-Language
header	I-Language
,	O
also	O
forms	O
the	O
basis	O
for	O
its	O
modules	O
mechanism	O
.	O
</s>
<s>
It	O
uses	O
the	O
same	O
bitcode	O
file	O
format	O
that	O
is	O
employed	O
by	O
LLVM	B-Application
,	O
encapsulated	O
in	O
clang-specific	O
sections	O
within	O
Common	O
Object	O
File	O
Format	O
or	O
Extensible	O
Linking	O
Format	O
files	O
.	O
</s>
<s>
In	O
the	O
default	O
project	O
configuration	O
,	O
the	O
C++Builder	B-Language
compiler	B-Language
implicitly	O
generates	O
precompiled	B-Language
headers	I-Language
for	O
all	O
headers	O
included	B-Language
by	O
a	O
source	O
module	O
until	O
the	O
line	O
#pragma	O
hdrstop	O
is	O
found	O
.	O
</s>
<s>
Precompiled	B-Language
headers	I-Language
are	O
shared	O
for	O
all	O
modules	O
of	O
the	O
project	O
if	O
possible	O
.	O
</s>
<s>
For	O
example	O
,	O
when	O
working	O
with	O
the	O
Visual	B-Library
Component	I-Library
Library	I-Library
,	O
it	O
is	O
common	O
to	O
include	O
the	O
vcl.h	O
header	O
first	O
which	O
contains	O
most	O
of	O
the	O
commonly	O
used	O
VCL	O
header	B-Language
files	I-Language
.	O
</s>
<s>
Thus	O
,	O
the	O
precompiled	B-Language
header	I-Language
can	O
be	O
shared	O
across	O
all	O
project	O
modules	O
,	O
which	O
dramatically	O
reduces	O
the	O
build	O
times	O
.	O
</s>
<s>
In	O
addition	O
,	O
C++Builder	B-Language
can	O
be	O
instrumented	O
to	O
use	O
a	O
specific	O
header	B-Language
file	I-Language
as	O
precompiled	B-Language
header	I-Language
,	O
similar	O
to	O
the	O
mechanism	O
provided	O
by	O
Visual	B-Application
C++	I-Application
.	O
</s>
<s>
C++Builder	B-Language
2009	O
introduces	O
a	O
"	O
Precompiled	B-Language
Header	I-Language
Wizard	O
"	O
which	O
parses	B-Language
all	O
source	O
modules	O
of	O
the	O
project	O
for	O
included	B-Language
header	B-Language
files	I-Language
,	O
classifies	O
them	O
(	O
i.e.	O
</s>
<s>
excludes	O
header	B-Language
files	I-Language
if	O
they	O
are	O
part	O
of	O
the	O
project	O
or	O
do	O
not	O
have	O
an	O
Include	B-Language
guard	I-Language
)	O
and	O
generates	O
and	O
tests	O
a	O
precompiled	B-Language
header	I-Language
for	O
the	O
specified	O
files	O
automatically	O
.	O
</s>
<s>
A	O
pretokenized	O
header	O
(	O
PTH	O
)	O
is	O
a	O
header	B-Language
file	I-Language
stored	O
in	O
a	O
form	O
that	O
has	O
been	O
run	O
through	O
lexical	B-Application
analysis	I-Application
,	O
but	O
no	O
semantic	O
operations	O
have	O
been	O
done	O
on	O
it	O
.	O
</s>
<s>
PTH	O
is	O
present	O
in	O
Clang	B-Application
before	O
it	O
supported	O
PCH	O
,	O
and	O
has	O
also	O
been	O
tried	O
in	O
a	O
branch	O
of	O
GCC	B-Application
.	O
</s>
<s>
Compared	O
to	O
a	O
full	O
PCH	O
mechanism	O
,	O
PTH	O
has	O
the	O
advantages	O
of	O
language	O
(	O
and	O
dialect	O
)	O
independence	O
,	O
as	O
lexical	B-Application
analysis	I-Application
is	O
similar	O
for	O
the	O
C-family	O
languages	O
,	O
and	O
architecture	O
independence	O
,	O
as	O
the	O
same	O
stream	O
of	O
tokens	O
can	O
be	O
used	O
when	O
compiling	B-Language
for	O
different	O
target	O
architectures	O
.	O
</s>
<s>
It	O
however	O
has	O
the	O
disadvantage	O
of	O
not	O
going	O
any	O
further	O
than	O
simple	O
lexical	B-Application
analysis	I-Application
,	O
requiring	O
that	O
syntactic	B-Language
and	O
semantic	O
analysis	O
of	O
the	O
token	O
stream	O
be	O
performed	O
with	O
every	O
compilation	B-Language
.	O
</s>
<s>
In	O
addition	O
,	O
the	O
time	O
to	O
compile	B-Language
scaling	O
linearly	O
with	O
the	O
size	O
,	O
in	O
lexical	O
tokens	O
,	O
of	O
the	O
pretokenized	O
file	O
,	O
which	O
is	O
not	O
necessarily	O
the	O
case	O
for	O
a	O
fully-fledged	O
precompilation	O
mechanism	O
(	O
PCH	O
in	O
clang	B-Application
allows	O
random	O
access	O
)	O
.	O
</s>
<s>
Clang	B-Application
's	O
pretokenization	O
mechanism	O
includes	O
several	O
minor	O
mechanisms	O
for	O
assisting	O
the	O
pre-processor	O
:	O
caching	O
of	O
file	O
existence	O
and	O
datestamp	O
information	O
,	O
and	O
recording	O
inclusion	B-Language
guards	I-Language
so	O
that	O
guarded	O
code	O
can	O
be	O
quickly	O
skipped	O
over	O
.	O
</s>
