From the standard, section 16.2
1. A #include directive shall identify a header or source file that
can be processed by the implementation.
2. A preprocessing directive of the form # include
<hcharsequence> newline searches a sequence of implementation
defined places for a header identified uniquely by the
specifiedsequence between the < and > delimiters, and causes the
replacement of that directive by the entire contentsof the header.
How the places are specified or the header identified is
implementation defined.
3. A preprocessing directive of the form # include
"qcharsequence" newline causes the replacement of that
directive by the entire contents of the source file identified by
the specified sequence between the " delimiters. The named source
file is searched for in an implementationdefined manner. If this
search is not supported, or if the search fails, the directive is
reprocessed as if it read # include <hcharsequence> newline
with the identical contained sequence (including > characters,
if any) from the original directive.
In other words, the <> form looks in system-specified places, whereas
the "" form looks in a (possibly) different set of system specified
places then, if that doesn't locate the file, it looks in the same
places as <> would have looked.
In practical terms, <> looks in the system include directory, whereas ""
looks in the directory containing the file being compiled, _then_ looks
in the system include directory.
Avik Ghose wrote:
> Hi all,
> I have this slight confusion regarding how the two are different.
> #include <foo.h>
> #include "foo.h"
> I mean how does GNU make and gcc differentiate while searching for the
> include file in both the cases.
> Thanks in advance.
> Have a nice day!
>
>
>
> Thanx and Regards
> Avik Ghose
>
> *SMS* <http://in.mobile.yahoo.com/new/pc/> using the Yahoo!
> *Messenger* <http://in.mobile.yahoo.com/new/pc/>*;* *Download
> <http://in.messenger.yahoo.com/>* latest version.
>
|