<s>
In	O
the	O
C	B-Language
and	O
C++	B-Language
programming	I-Language
languages	I-Language
,	O
an	O
#include	O
guard	O
,	O
sometimes	O
called	O
a	O
macro	B-Language
guard	I-Language
,	O
header	B-Language
guard	I-Language
or	O
file	O
guard	O
,	O
is	O
a	O
particular	O
construct	O
used	O
to	O
avoid	O
the	O
problem	O
of	O
double	O
inclusion	O
when	O
dealing	O
with	O
the	O
include	B-Language
directive	I-Language
.	O
</s>
<s>
The	O
C	B-Language
preprocessor	I-Language
processes	O
directives	O
of	O
the	O
form	O
#include	O
<file>	O
in	O
a	O
source	O
file	O
by	O
locating	O
the	O
associated	O
file	O
on	O
disk	B-Application
and	O
transcluding	O
(	O
"	O
including	O
"	O
)	O
its	O
contents	O
into	O
a	O
copy	O
of	O
the	O
source	O
file	O
known	O
as	O
the	O
translation	B-Language
unit	I-Language
,	O
replacing	O
the	O
include	B-Language
directive	I-Language
in	O
the	O
process	O
.	O
</s>
<s>
The	O
files	O
included	O
in	O
this	O
regard	O
are	O
generally	O
header	B-Language
files	I-Language
,	O
which	O
typically	O
contain	O
declarations	O
of	O
functions	O
and	O
classes	O
or	O
structs	B-Language
.	O
</s>
<s>
If	O
certain	O
C	B-Language
or	O
C++	B-Language
language	I-Language
constructs	O
are	B-Language
defined	I-Language
twice	I-Language
,	O
the	O
resulting	O
translation	B-Language
unit	I-Language
is	B-Error_Name
invalid	I-Error_Name
.	O
</s>
<s>
The	O
addition	O
of	O
#include	O
guards	O
to	O
a	O
header	B-Language
file	I-Language
is	O
one	O
way	O
to	O
make	O
that	O
file	O
idempotent	O
.	O
</s>
<s>
Another	O
construct	O
to	O
combat	O
double	O
inclusion	O
is	O
#pragma	B-Language
once	I-Language
,	O
which	O
is	O
non-standard	O
but	O
nearly	O
universally	O
supported	O
among	O
C	B-Language
and	O
C++	B-Language
compilers	B-Language
.	O
</s>
<s>
The	O
following	O
C	B-Language
code	O
demonstrates	O
a	O
real	O
problem	O
that	O
can	O
arise	O
if	O
#include	O
guards	O
are	O
missing	O
:	O
</s>
<s>
Here	O
,	O
the	O
file	O
"	O
child.c	O
"	O
has	O
indirectly	O
included	O
two	O
copies	O
of	O
the	O
text	O
in	O
the	O
header	B-Language
file	I-Language
"	O
grandparent.h	O
"	O
.	O
</s>
<s>
This	O
causes	O
a	O
compilation	B-Error_Name
error	I-Error_Name
,	O
since	O
the	O
structure	O
type	O
foo	O
will	O
thus	O
be	O
defined	O
twice	O
.	O
</s>
<s>
In	O
C++	B-Language
,	O
this	O
would	O
be	O
called	O
a	O
violation	O
of	O
the	O
one	B-Language
definition	I-Language
rule	I-Language
.	O
</s>
<s>
The	O
C	B-Language
preprocessor	I-Language
preprocesses	O
the	O
header	B-Language
files	I-Language
,	O
including	O
and	O
further	O
preprocessing	O
them	O
recursively	O
.	O
</s>
<s>
When	O
"	O
child.c	O
"	O
includes	O
"	O
grandparent.h	O
"	O
at	O
the	O
second	O
time	O
(	O
while	O
including	O
"	O
parent.h	O
"	O
)	O
,	O
as	O
the	O
#ifndef	O
test	O
returns	O
false	O
,	O
the	O
preprocessor	O
skips	O
down	O
to	O
the	O
#endif	O
,	O
thus	O
avoiding	O
the	O
second	O
definition	O
of	O
struct	B-Language
foo	O
.	O
</s>
<s>
Different	O
naming	O
conventions	O
for	O
the	O
guard	O
macro	O
may	O
be	O
used	O
by	O
different	O
programmers	B-Application
.	O
</s>
<s>
Of	O
course	O
,	O
it	O
is	O
important	O
to	O
avoid	O
duplicating	O
the	O
same	O
include-guard	O
macro	O
name	O
in	O
different	O
header	B-Language
files	I-Language
,	O
as	O
including	O
the	O
1st	O
will	O
prevent	O
the	O
2nd	O
from	O
being	O
included	O
,	O
leading	O
to	O
the	O
loss	O
of	O
any	O
declarations	O
,	O
inline	O
definitions	O
,	O
or	O
other	O
#includes	O
in	O
the	O
2nd	O
header	O
.	O
</s>
<s>
Therefore	O
,	O
a	O
project	O
using	O
#include	O
guards	O
must	O
work	O
out	O
a	O
coherent	O
naming	O
scheme	O
for	O
its	O
include	B-Language
guards	I-Language
,	O
and	O
make	O
sure	O
its	O
scheme	O
does	O
n't	O
conflict	O
with	O
that	O
of	O
any	O
third-party	O
headers	O
it	O
uses	O
,	O
or	O
with	O
the	O
names	O
of	O
any	O
globally	O
visible	O
macros	O
.	O
</s>
<s>
For	O
this	O
reason	O
,	O
most	O
C	B-Language
and	O
C++	B-Language
implementations	O
provide	O
a	O
non-standard	O
#pragma	B-Language
once	I-Language
directive	O
.	O
</s>
<s>
This	O
directive	O
,	O
inserted	O
at	O
the	O
top	O
of	O
a	O
header	B-Language
file	I-Language
,	O
will	O
ensure	O
that	O
the	O
file	O
is	O
included	O
only	O
once	O
.	O
</s>
<s>
The	O
Objective-C	B-Language
language	O
(	O
which	O
is	O
a	O
superset	O
of	O
C	B-Language
)	O
introduced	O
an	O
#import	O
directive	O
,	O
which	O
works	O
exactly	O
like	O
#include	O
,	O
except	O
that	O
it	O
includes	O
each	O
file	O
only	O
once	O
,	O
thus	O
obviating	O
the	O
need	O
for	O
#include	O
guards	O
.	O
</s>
<s>
PL/I	B-Language
uses	O
the	O
%INCLUDE	O
statement	O
as	O
the	O
equivalent	O
to	O
C	B-Language
's	O
#include	O
directive	O
.	O
</s>
<s>
IBM	O
Enterprise	O
PL/I	B-Language
also	O
supports	O
the	O
%XINCLUDE	O
statement	O
which	O
will	O
"	O
incorporate	O
external	O
text	O
into	O
the	O
source	O
program	O
if	O
it	O
has	O
not	O
previously	O
been	O
included.	O
"	O
</s>
<s>
This	O
differs	O
from	O
the	O
C	B-Language
#pragma	B-Language
once	I-Language
in	O
that	O
the	O
program	O
including	O
the	O
external	O
text	O
is	O
responsible	O
for	O
specifying	O
that	O
duplicate	O
text	O
should	O
not	O
be	O
included	O
,	O
rather	O
than	O
the	O
included	O
text	O
itself	O
.	O
</s>
