0

I would like an explanation of the difference between < header.h > and "header.h" in library #include directives. How exactly (in which locations) does the linker search for the files? In what order does it perform the search?


1 답변


0

When we write <stdio.h> , we are referring to a header file which is available in the include directory of the system. When we write #include <stdio.h>, the preprocessor searches for the header file in the system include directory and not in the current directory. When we write #include "stdio.h", the preprocessor starts searching for this header file in the current directory and then in its parent directories. So if we write our own stdio.h, save it in the current directory, and include it in the program using #include "stdio.h" then our header will be included instead of the system header.

In short, if we use angular brackets (<>) then we are indicating that the file can be found in one if the standard directories in the system. If we use quotation marks (" ") then we are indicating that a non-standard header is being used.


  • This is not necessarily true. The difference between these preprocessor directives is implementation-dependent. The only sure way to determine the difference is to read the documentation for your particular compiler. - David Schwartz
  • "the preprocessor starts searching for this header file in the current directory and then in its parent directories." In the parent directories? Never heard of. That is not to say that there is no compiler which would implement it that way. - glglgl

Linked


Related

Latest