可能重复:
What is the difference between #include <filename> and #include “filename”?路径包括
我创建一个共享的C库。有包括
#include <mylib/someheader.h>
与
#include "mylib/someheader.h"
从*.c
或该库的*.h
文件时有什么区别?
可能重复:
What is the difference between #include <filename> and #include “filename”?路径包括
我创建一个共享的C库。有包括
#include <mylib/someheader.h>
与
#include "mylib/someheader.h"
从*.c
或该库的*.h
文件时有什么区别?
第一个版本用于系统标题,第二个用于外部标题。 虽然大多数编译器都会找到正确的头文件,无论使用哪种符号。
我相信两者都会搜索相同的地方,区别在于<>先搜索库位置,然后“”先搜索用户位置。 – Wug 2012-08-01 19:33:33
所以基本上,如果这涉及gcc,总会有阅读该手册的选项:http://gcc.gnu.org/onlinedocs/gcc-4.7.1/cpp/Include-Syntax.html – LodeRunner 2012-08-01 19:35:43
使用引号时,它是您自己的头文件。 – squiguy 2012-08-01 19:30:40
此外,如果您忽略标题的路径并仅包含名称,它会使大型项目更具可读性。您可以使用-I标志为gcc指定其他include目录,例如:'gcc -c somefile.c -o someobj.o -I。/ mylib' – Wug 2012-08-01 19:32:16
@Wug:这可能导致恶意冲突。 – Cartesius00 2012-08-01 19:33:55