Possible Duplicate:
What is the difference between #include <filename> and #include “filename”?
Why doesn't the compiler complain when I write the following:
#include "stdio.h"
Shouldn't it be
#include <stdio.h>
instead, because stdio.h is actually stored in a library folder and not in the folder of the translation unit? Why does it work anyway?
The difference between ""
and <>
isn't much. Both search for the header in implementation-defined places1, 2. The difference is that if that search fails for ""
, the search happens as if it was using <>
. (§16.2)
Basically, this means that if <>
finds a header with a certain name, ""
does not fail to find a header with the same name3.
1 These implementation-defined places do not have to be the same for both forms.
2 There is no requirement that one of these search library folders and the other search the folder of the TU. The compiler is allowed to search the whole filesystem and even google for it if it wants.
3 This does not mean that they always find the same header, though.
This is because of how the include syntax is defined.
#include <cstdio>
means that the compiler should include the standard library cstdio
#include "cstdio"
means the compiler should try to find the file "cstdio", looking primarily in the current directory and using the location of the standard libraries as a fallback.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With