#include "some.h"
and
#include <some.h>
...">
The difference is where the preprocessor will start searching for the file some.h. If you use the #include "some.h"
directive, then the local (with respect to the project) file inclusion folders will be viewed first. If you use #include <some.h>
, then the global (with respect to the project) file inclusion folders will be viewed first. Global include folders are folders specified in the development environment settings, local ones are those specified in the project settings.
According to Chapter 16.2 Source file inclusion [cpp.include]
, the difference between "path"
and <path>
is that "path"
does the same thing as <path>
, but first it will search in some additional set of files.
In existing compilers, this is implemented as follows:
#include <path>
searches in paths passed to the compiler using the command line parameter ( -I
), in paths set by environment variables, in paths entered into the compiler.
#include "path"
searches in the directory in which the current file is located, and then searches in the same place as #include <path>
.
In VC ++, #include "path"
also searches for directories of other files included in this translation unit.
In G ++, #include "path"
also searches for directories specified in the command-line parameter -iquote
.
It is not clear, but what will happen next? If the directive #include "some.h" is used and the file is not found in local folders, then the search will be performed in global ones. If the #include directive is used, the search in local folders will not be performed, but immediately start searching in global folders.
You can create your own library in header files, let's say the popular "iostream.h"
So, if you write "iostream.h" in a project, it will use your header file. And if <iostream.h>
global.
Source: https://ru.stackoverflow.com/questions/149/
All Articles