For Programmers: Free Programming Magazines  


Home > Archive > VC Language > June 2005 > Re: what's the different between #incldue " xxx" and #include <xxx









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: what's the different between #incldue " xxx" and #include <xxx
Roland Frank

2005-06-07, 9:02 am

Hi boki,

although the previous posters quite correctly explained
what difference it makes with VC++ to use the "" or <> form
of the #include directive, they completely fail to explain
WHY there are two different forms in the first place.
This all originates in the C++ standard.
The "" version dates all back to the days C was invented
and means in short "include the given files here" using an
implementation defined search sequence for the file name
between the "".
The <> version is quite different. Avoiding the legalese of
the standard it means that the char sequence between the
brackets does NOT necessarily denote a file name. It says
that it "uniquely identifies a header" in a implementation
defined way. This could for example mean that the identifier
between <> is an index into a database and the header fetched
from there.
I think the rationale behind this was, that on some operation
system it might be illegal to use filenames without extensions
or that there might be a restriction in the length of filenames.
For example #include <exception> might be an illegal filename
(it is on DOS). The creators of the standard wanted to make shure
that a program that includes the headers as defined in the standard
to correctly compile on all platforms without changes. So, a DOS
compiler could lookup the <exception> in the example in a file,
find the filename "exceptio.hhh" and then use this filename instead.

VC++ implementation of the <> is completely conforming to the
standard but I wouldn't use the <> form for anything else but
the headers of the standard library, as you might be in for a
big surprise if you switch compilers and use the <> as simply
a means for including files with a different search sequence.

Regards,
Roland
Roland Frank

2005-06-07, 9:02 am

Hello Sergei,


You are right, but in C it worked like VC++ implements it today:
Don't look up the file in the source files directory first, but
it still defined the character sequence between the brackets to
be a filename.
C++ dropped this filename business completely and made the transition
between the character sequence between the <> and the actual header
completely implementation defined. It extreme cases it could mean,
that all standard headers could be stored in a database instead of
files - or to be included my magic alltogether. Or your compiler
could lookup <> headers over the internet and download them everytime
(only for your good of course).....

[color=darkred]
>
>
> Pardon, I see now that it's 9 char long.


Those who can count have an advantage sometimes :-)

Regards,
Roland
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com