what is the difference? I work in Visual Studio 2010. I added a directory in Project Properties → Linker → General → Add...">

Include "file.h" vs <file> what is the difference?

I work in Visual Studio 2010. I added a directory in Project Properties → Linker → General → Additional Directories

The project compiles if I use

"file.h" 

but not if i use

  <file> 
+4
source share
3 answers

You probably assume that < > implicitly adds .h to the end of the file name. It is not true. Whether you use < > or " " does not matter for the file name. It mainly talks about the implementation in which order it should go, including directories, in order to find the header file.

To quote the standard:

Form preprocessing directive # include <h-char-sequence> new-line
it searches for a sequence of definitions defined for implementation for a header that is uniquely identified by a specific sequence between the < and > delimiters, and causes this directive to be replaced with the entire contents of the header. As places are indicated, or the header identifier is defined as an implementation.

Form preprocessing directive # include "q-char-sequence" new-line
causes the directive to be replaced with all the contents of the source file identified by the specified sequence between the delimiters. " named source file is executed in a search method. If this search is not supported or if the search is not performed, the directive is processed as if it were reading

# include <h-char-sequence> new-line
with an identical contained sequence (including > characters, if any) from the original directive

+11
source

"" for local files and <> for files in the C library.

+5
source

An include only works if such a file exists. In your case, this may be the reason for the file.h file, but notice just the file .

You probably think that it should work everywhere since you could see it with iostream.h and iostream . This is because these are two different files that mean two different things .

+1
source

Source: https://habr.com/ru/post/1381590/


All Articles