Topic: #include: difference between <> and


Author: MikeAlpha@NoSpam_csi.com (Martin Aupperle)
Date: Thu, 31 May 2001 23:21:24 GMT
Raw View
On Wed, 30 May 2001 19:28:13 GMT, kanze@gabi-soft.de (James Kanze)
wrote:

>MikeAlpha@NoSpam_csi.com (Martin Aupperle) wrote in message news:<3b13f2dd.382111276@news.nikoma.de>...
>
>> Thanks, guys - but doesn't that mean that a program that contains
>> the line
>
>> #include "module1/header.h"
>
>> is not necessarily portable? (because the meaning is implementation
>> defined?)
>
>Yes.
>
>While this particular include means the same on all of the compilers I
>have access to, I've often seen code with:
>
>    #include "module1\\header.h"
>
>This will work on some of my systems, but not on others.
>



Yes yes - we all know MS and its backslashes.

Maybe I should be more specific. From what I learned, a
(preprocessor!) line like

 #include "module1/header.h"

renders the program not truly portable because the search rules to
find header1 are plattform specific. Can that really be?


------------------------------------------------
Martin Aupperle
MikeAlpha@NoSpam_csi.com
(remove NoSpam_)
------------------------------------------------

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: "James Kuyper Jr." <kuyper@wizard.net>
Date: Fri, 1 Jun 2001 00:39:17 GMT
Raw View
Martin Aupperle wrote:
...
> Maybe I should be more specific. From what I learned, a
> (preprocessor!) line like
>
>  #include "module1/header.h"
>
> renders the program not truly portable because the search rules to
> find header1 are plattform specific. Can that really be?

Yes. As I've already said, "Everything else about these directives is
implementation-defined".

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: kanze@gabi-soft.de (James Kanze)
Date: Wed, 30 May 2001 19:28:13 GMT
Raw View
MikeAlpha@NoSpam_csi.com (Martin Aupperle) wrote in message news:<3b13f2dd.382111276@news.nikoma.de>...

> Thanks, guys - but doesn't that mean that a program that contains
> the line

> #include "module1/header.h"

> is not necessarily portable? (because the meaning is implementation
> defined?)

Yes.

While this particular include means the same on all of the compilers I
have access to, I've often seen code with:

    #include "module1\\header.h"

This will work on some of my systems, but not on others.

--
James Kanze                               mailto:kanze@gabi-soft.de
Conseils en informatique orient   e objet/
                   Beratung in objektorientierter Datenverarbeitung
Ziegelh   ttenweg 17a, 60598 Frankfurt, Germany Tel. +49(069)63198627

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: MikeAlpha@NoSpam_csi.com (Martin Aupperle)
Date: Tue, 29 May 2001 21:36:38 GMT
Raw View
>James Kuyper wrote
>The key difference is that with "", if the initial
>implementation-defined search fails, it then carries out the same
>implementation-defined search used for <>. That only matters if the ""
>search will fail for some headers that the <> search can find.
>Everything else about these directives is implementation-defined.

>Jim Hyslop wrote
>
>Basically, what it boils down to is this:
>
>#include <>
>
>tells the compiler "search in location A" (where "location A"
>is defined by the compiler).
>
>#include ""
>
>tells the compiler "search in location B, and if you can't find it,
>then look in location A."
>(where, again, "location B" is defined by the compiler).

Thanks, guys - but doesn't that mean that a program that contains the
line

#include "module1/header.h"

is not necessarily portable? (because the meaning is implementation
defined?)






------------------------------------------------
Martin Aupperle
MikeAlpha@NoSpam_csi.com
(remove NoSpam_)
------------------------------------------------

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: Ron Natalie <ron@spamcop.net>
Date: Tue, 29 May 2001 21:52:28 GMT
Raw View

Martin Aupperle wrote:
>
>
> Thanks, guys - but doesn't that mean that a program that contains the
> line
>
> #include "module1/header.h"
>
> is not necessarily portable? (because the meaning is implementation
> defined?)
>

Yep.  Once you stray from the standard headers every other header name
is implementation defined.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: jim.hyslop@leitch.com
Date: Thu, 17 May 2001 21:16:24 GMT
Raw View
In article <3afb8319.79418017@news.nikoma.de>, Martin Aupperle
<MikeAlpha@NoSpam_csi.com> writes:
>Hello,
>can someone please explain where the difference between
>
> #include <file.h>
>
>and
>
> #include "file.h"
>
>is? The Standard only says in 16.2. that in both cases a list of
>implementation defined places is searched, although the wording is
>slightly different for both forms.
Yes, and it is that slight difference in wording that makes the difference,
if ya see what I mean ;-)

Basically, what it boils down to is this:

#include <>

tells the compiler "search in location A" (where "location A"
is defined by the compiler).

#include ""

tells the compiler "search in location B, and if you can't find it,
then look in location A."
(where, again, "location B" is defined by the compiler).

"location A" is usually defined as the location of the standard headers,
plus any other directories you specify (for example, by setting an
environment
variable, or using a command line parameter).

"location B" is sometimes defined as 'the same directory as the .cpp file'.

>Why does the Standard not mention extensionless headers of the
>Standard Library here? Are there additional rules?
No. It does not matter what extension the file uses. You can use, for
example:

#include <a.cpp>
#include "list.txt"
#include <foo.bar>

As long as the files contain valid C++ code, your program will compile.

--
Jim

 -----  Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web  -----
  http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
   NewsOne.Net prohibits users from posting spam.  If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse@newsone.net

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: MikeAlpha@NoSpam_csi.com (Martin Aupperle)
Date: Mon, 14 May 2001 11:17:47 GMT
Raw View
Hello,
can someone please explain where the difference between

 #include <file.h>

and

 #include "file.h"

is? The Standard only says in 16.2. that in both cases a list of
implementation defined places is searched, although the wording is
slightly different for both forms.

Why does the Standard not mention extensionless headers of the
Standard Library here? Are there additional rules?

------------------------------------------------
Martin Aupperle
MikeAlpha@NoSpam_csi.com
(remove NoSpam_)
------------------------------------------------

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: "James Kuyper Jr." <kuyper@wizard.net>
Date: Mon, 14 May 2001 14:52:47 GMT
Raw View
Martin Aupperle wrote:
>
> Hello,
> can someone please explain where the difference between
>
>         #include <file.h>
>
> and
>
>         #include "file.h"
>
> is? The Standard only says in 16.2. that in both cases a list of
> implementation defined places is searched, although the wording is
> slightly different for both forms.

The key difference is that with "", if the initial
implementation-defined search fails, it then carries out the same
implementation-defined search used for <>. That only matters if the ""
search will fail for some headers that the <> search can find.
Everything else about these directives is implementation-defined.

> Why does the Standard not mention extensionless headers of the
> Standard Library here? Are there additional rules?

Because "extensions" on headers are implementation-specific (usually, it
depends upon which operating system you use, but that's up to the
implementation - an implementation isn't actually required to reflect
the operating system its operating under; it could emulate an entirely
different one). The standard has a little bit of special handling for
certain types of headers containing "." (6.10.2p5), apparantly to allow
users to define header names that are guaranteed to be portable, but the
basic idea is that there's nothing special about "." in a header name as
far as C++ is concerned.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]