Possible Duplicate:
what is the difference between #include <filename> and #include “filename”可能重复:#include
和#include“filename”之间的区别是什么
In both cases there is no error ...Is there any difference between them ?
在这两种情况下都没有错误......它们之间有什么区别吗?
10 个解决方案
#1
8
<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.
理想情况下,您可以将<...>用于标准C库,将“...”用于您编写并存在于当前目录中的库。
#2
6
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).
指定第二个版本首先在实现定义的位置搜索,然后如果找不到该文件,则在与<...>版本相同的位置搜索,该版本搜索通常由-I命令行指定的路径选项和内置包含路径(指向标准库和系统头的位置)。
Usually, implementations define that location to be relative to the location of the including file.
通常,实现将该位置定义为相对于包含文件的位置。
#3
2
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.
至于为什么它们都适合你,也许你的编译器也会在库头文件中查找文件名,以防它们在你的库中找不到。
#4
2
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".
当你想说:“在系统的include目录中查找具有此名称的文件”时,可以使用#include。当你想说:“在我自己的应用程序的include目录中查找具有此名称的文件时,使用#include”doublequoted“;但是,如果找不到它,请查看系统的include目录”。
#5
1
I case of "" compiler first search the header file in your local directory where your .c file presents
我的“”编译器首先搜索你的.c文件所在的本地目录中的头文件
while in case of <> compiler only search in header file folder
而在<>编译器的情况下只搜索头文件夹
#6
1
#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.
#include
see http://gcc.gnu.org/onlinedocs/gcc-2.95.3/cpp_1.html#SEC6
见http://gcc.gnu.org/onlinedocs/gcc-2.95.3/cpp_1.html#SEC6
#7
1
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.
对于我使用的编译器,“...”开始在与正在编译的源文件相同的目录中查找包含文件,然后是包含路径。在include路径中包含<...> start,跳过当前die,除非它在include路径中。
#8
1
Normally standard header files are enclosed by < > and other user specific files are specifed with " .
通常标准头文件由<>括起,其他用户特定文件用“。”指定。
#9
0
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.
不同之处在于开发人员生成的头文件用“”括起来。已包含在系统中的头文件包含在<>中。如果放置的目录不在编译器的搜索路径中,那么即使<>标头也需要-I指令。
Bottom line: Your headers with "", system headers with <>
底线:标题为“”,系统标题为<>
#10
0
<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.
当指令使用“时,将以实现定义的方式搜索源文件,如果找不到,则重新处理该指令,就好像它首先用 <和> 编写一样。
#1
8
<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.
理想情况下,您可以将<...>用于标准C库,将“...”用于您编写并存在于当前目录中的库。
#2
6
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).
指定第二个版本首先在实现定义的位置搜索,然后如果找不到该文件,则在与<...>版本相同的位置搜索,该版本搜索通常由-I命令行指定的路径选项和内置包含路径(指向标准库和系统头的位置)。
Usually, implementations define that location to be relative to the location of the including file.
通常,实现将该位置定义为相对于包含文件的位置。
#3
2
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.
至于为什么它们都适合你,也许你的编译器也会在库头文件中查找文件名,以防它们在你的库中找不到。
#4
2
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".
当你想说:“在系统的include目录中查找具有此名称的文件”时,可以使用#include。当你想说:“在我自己的应用程序的include目录中查找具有此名称的文件时,使用#include”doublequoted“;但是,如果找不到它,请查看系统的include目录”。
#5
1
I case of "" compiler first search the header file in your local directory where your .c file presents
我的“”编译器首先搜索你的.c文件所在的本地目录中的头文件
while in case of <> compiler only search in header file folder
而在<>编译器的情况下只搜索头文件夹
#6
1
#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.
#include
see http://gcc.gnu.org/onlinedocs/gcc-2.95.3/cpp_1.html#SEC6
见http://gcc.gnu.org/onlinedocs/gcc-2.95.3/cpp_1.html#SEC6
#7
1
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.
对于我使用的编译器,“...”开始在与正在编译的源文件相同的目录中查找包含文件,然后是包含路径。在include路径中包含<...> start,跳过当前die,除非它在include路径中。
#8
1
Normally standard header files are enclosed by < > and other user specific files are specifed with " .
通常标准头文件由<>括起,其他用户特定文件用“。”指定。
#9
0
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.
不同之处在于开发人员生成的头文件用“”括起来。已包含在系统中的头文件包含在<>中。如果放置的目录不在编译器的搜索路径中,那么即使<>标头也需要-I指令。
Bottom line: Your headers with "", system headers with <>
底线:标题为“”,系统标题为<>
#10
0
<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.
当指令使用“时,将以实现定义的方式搜索源文件,如果找不到,则重新处理该指令,就好像它首先用 <和> 编写一样。