By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,238 Members | 1,804 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,238 IT Pros & Developers. It's quick & easy.

#include -- double quotes vs. angle brackets

P: n/a
Hi,

I'm aware that both quoted and angle-bracketed strings in an #include
directive result in implementation-defined file lookup, differing in the
fact that #include "foo.h" first checks *something* and then falls back to
the same behaviour as #include <foo.h>.

Now, in reality #include <foo.h> generally results in file name being
checked up in explicitly specified locations (-I command line options,
system header locations), while the double quoted version gets the current
directory checked first.

My question is:
- Is that the current working directory? E.g. the directory from which the
compiler is being run.
- Or, the directory where the file with the said #include directive being
parsed is lying?

What's the common behaviour?

Cheers.
--
:: bartekd [at] o2 [dot] pl

Jul 22 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
bartek wrote:
My question is:
- Is that the current working directory? E.g. the directory from
which the compiler is being run.
- Or, the directory where the file with the said #include directive
being parsed is lying?


The latter is common. The former would make not much sense, since
application-specific header files are rarely in the same directory as the
compiler.

Also note that, at least in Windows, the current working directory need not
actually be the directory that contains the executable. The compiler might
change the current working directory to the location of the compiled source
file, and then look for the header file in the working directory, resulting
in the same behaviour as option 2.

--
Unforgiven

Jul 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.