Google Gruppi non supporta più i nuovi post o le nuove iscrizioni Usenet. I contenuti storici continuano a essere visibili.

Differences between <headerfile.h> and "headerfile"

13 visualizzazioni
Passa al primo messaggio da leggere

Christian

da leggere,
10 feb 2008, 10:15:2110/02/08
a
I've found a program that has #include <fstream.h> as include
directive. Visual Studio can't find it,but if I write #include
"fstream" it can find it. I cannot understand how Visual Studio
operate in this case and its notations. Someone could explain it to
me? Thanks.

Igor Tandetnik

da leggere,
10 feb 2008, 10:33:2510/02/08
a
"Christian" <voodoo8...@gmail.com> wrote in message
news:8ee75de5-f21f-4a80...@i12g2000prf.googlegroups.com

> I've found a program that has #include <fstream.h> as include
> directive. Visual Studio can't find it,but if I write #include
> "fstream" it can find it. I cannot understand how Visual Studio
> operate in this case and its notations.

The difference is likely not in angle brackets vs quotes. Note how in
one case the file name is fstream.h, and in the other it's just fstream.
The former was used in VC6 and earlier, was deprecated in VC6 and was
removed in subsequent version. The latter (fstream without an extension)
is modern, standard-conformant header file name.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


Christian

da leggere,
10 feb 2008, 10:58:1210/02/08
a
> The difference is likely not in angle brackets vs quotes. Note how in
> one case the file name is fstream.h, and in the other it's just fstream.
> The former was used in VC6 and earlier, was deprecated in VC6 and was
> removed in subsequent version. The latter (fstream without an extension)
> is modern, standard-conformant header file name.
> --
> With best wishes,
> Igor Tandetnik

thanks Igor :)


Ulrich Eckhardt

da leggere,
11 feb 2008, 03:32:3311/02/08
a

Several things here:
1. The C++ standard defines a bunch of headers (e.g. 'fstream'
and 'iostream'). Those are included with #include <fstream>. Everything
else, like e.g. windows.h is not a C++ header. Note also that C++ doesn't
require these headers to actually be implemented as files, it could be some
compiler-internal data structure activated there.
2. In order to include a file in another file, C++ says you should use
#include "otherfile", e.g. #include "my class.h".
3. The distinction that C++ makes about headers is traditionally blurred.
That means that 'system' header files are also usually included with angled
brackets like #include <windows.h>. This is incorrect as far as C++ is
concerned but established practice.
4. For your own header files (i.e. those that are part of the project in
question), you should use the "" syntax and make the filenames end
with '.h' or '.hpp'.
5. 'fstream.h' is not a part of C++. This is a header of the old,
pre-standard IOStreams library. The IOStreams in the C++ standard are
templates and they all live in namespace std, so the contents
of 'fstream.h' and 'fstream' are not the same though they are similar. Do
not use fstream.h and be cautious of code that does!

Uli

Ben Voigt [C++ MVP]

da leggere,
11 feb 2008, 10:53:4311/02/08
a
Igor Tandetnik wrote:
> "Christian" <voodoo8...@gmail.com> wrote in message
> news:8ee75de5-f21f-4a80...@i12g2000prf.googlegroups.com
>> I've found a program that has #include <fstream.h> as include
>> directive. Visual Studio can't find it,but if I write #include
>> "fstream" it can find it. I cannot understand how Visual Studio
>> operate in this case and its notations.
>
> The difference is likely not in angle brackets vs quotes. Note how in
> one case the file name is fstream.h, and in the other it's just
> fstream. The former was used in VC6 and earlier, was deprecated in
> VC6 and was removed in subsequent version. The latter (fstream
> without an extension) is modern, standard-conformant header file name.

And the correct line is therefore:

#include <fstream>


Mark Salsbery [MVP]

da leggere,
12 feb 2008, 12:59:4512/02/08
a
I'm not sure if this was mentioned, but from the #include docs, the
difference between using <> and "":

"The difference between the two forms is the order in which the preprocessor
searches for header files when the path is incompletely specified."

There's a table there that shows the search orders for the two forms of
#include.

Just FYI,
Mark

--
Mark Salsbery
Microsoft MVP - Visual C++

"Christian" <voodoo8...@gmail.com> wrote in message

news:8ee75de5-f21f-4a80...@i12g2000prf.googlegroups.com...

0 nuovi messaggi