I case of "" compiler first search the header file in your local directory where your .c file presents
while in case of <> compiler only search in header file folder
I case of "" compiler first search the header file in your local directory where your .c file presents
while in case of <> compiler only search in header file folder
The second version is specified to search first in an implementation defined location, and afterwards if the file is not found, search in the same place as the <...>
version, which searches in the paths usually specified by the -I
command line option and by built-in include paths (pointing to the location of the standard library and system headers).
Usually, implementations define that location to be relative to the location of the including file.
<stdio.h>
searches in standard C library locations, whereas "stdio.h"
searches in the current directory as well.
Ideally, you would use <...>
for standard C libraries and "..."
for libraries that you write and are present in the current directory.
#include <something.h>
is meant for system headers, while #include "something.h"
is for headers of your own program. System headers are searched for in usual system directories (and those included with -I
argument), which your headers are searched for in current directory and then the same locations as system headers.
see http://gcc.gnu.org/onlinedocs/gcc-2.95.3/cpp_1.html#SEC6
For the compilers I've used, "..." starts looking for the include file in the same directory as the source file that is being compiled, then the include path. Includes with <...> start in the include path, skipping the current die unless it is in the include path.
Normally standard header files are enclosed by < > and other user specific files are specifed with " .
The <> tell the compiler to look for the file in the libraries' headers and "" tell it to look around among your application's headers.
As for why both of them works for you, maybe your compiler also looks for the filename in the library headers in case it didn't find one among yours.
<stdio.h>
refers to a header (not a header file)
"stdio.h"
refers to a source file.
Headers need not exist phisically in the implementation; the way they are identified is implementation-defined (usually the headers are files on specific directories)
When the directive uses "
, the source file is searched in an implementation-defined manner and, if not found, the directive is reprocessed as if it was written with <
and >
in the first place.
The difference is that header files made by the developer are enclosed by "". Header files that are already in the system are enclosed with <>. Even the <> headers need the -I directive if the directories that are placed are not in the search path of the compiler.
Bottom line: Your headers with "", system headers with <>
You use #include when you want to say: "look for a file with this name in the system's include directory". You use #include "doublequoted" when you want to say: "look for a file with this name in my own application's include directory; however, if it can't be found, look in the system's include directory".