Windows 7 - include

Asked By Carmen Sei on 19-Mar-08 10:04 PM
hi when include headers in VC++ what is different when using




Doug Harrison [MVP] replied on 19-Mar-08 09:28 PM
On Wed, 19 Mar 2008 18:04:20 -0800, Carmen Sei <fatwallet951@yahoo.com>


For non-absolute paths, the quoted form begins the search in the directory
of the file making the #include and falls back to the angle-bracket form if
it doesn't find the file there. For more, see:

The #include Directive
http://msdn2.microsoft.com/en-us/library/36k2cdd4.aspx

Actually, I see now there's an extra step (2):

1. In the same directory as the file that contains the #include statement.

2. In the directories of any previously opened include files in the reverse
order in which they were opened. The search starts from the directory of
the include file that was opened last and continues through the directory
of the include file that was opened first.

3. Like the angle brackets.

I would not recommend taking advantage of (2), because to rely on it is to
put yourself at the mercy of whomever #includes you. It seems to me it's a
recipe for ambiguity.

--
Doug Harrison
Visual C++ MVP
natha replied on 19-Mar-08 09:27 PM
In article <igh3u3tn2iqul12c5tni28srqjl5f648h2@4ax.com>,

Any beginning book on C/C++ should have a good answer, and probably
faster to read than waiting for answers on usenet.  Heck, searching
MSDN would probably find you an answer faster than usenet. For
example, you ought be be able to find this:
http://msdn2.microsoft.com/en-us/library/36k2cdd4(vs.80).aspx

Nathan Mates
--
Abhishek Padmanabh replied on 19-Mar-08 10:40 PM
I think (2) is ok, and should not cause issues regarding ambiguities. Is it
not just facilitating the order in which few already visited directories
would be searched (kind of a way to find an include file quickly - might not
be as quick sometimes if (3) doesn't skip the directories looked as in (2))?
Will (2) ever be out of the set of (1) union (3)?
Anders Karlsson replied on 21-Mar-08 09:35 AM
On Wed, 19 Mar 2008 18:04:20 -0800, Carmen Sei



in win32, and visual studio:

when you write


you are specifying a header that has nothing to do with your own
project i.e. the header is any standard header with the compiler e.g.
iostream

when you write "some.h"

you are saying the header is in my project/solution dir and is local
to your project.

hth
anders.
--
A: People bitching about top-posting
Doug Harrison [MVP] replied on 21-Mar-08 11:54 AM
On Fri, 21 Mar 2008 21:35:08 +0800, Anders Karlsson <anders43@gmai.foo>


Non-standard library headers are normally #included with this syntax as
well.


More generally, this syntax is used when the author of the file X making
the #include "a.h" wants to start the search for a.h in the directory
containing X.

--
Doug Harrison
Visual C++ MVP