#include<file.h>与#include"file.h"的区别

简介:
对于这种问题先来看一看外国人怎么想的,因为本来这种语言就是他们创造的,http://www.geekinterview.com/question_details/3379
 
 
What is the difference between #include <file> and #include “file”?
When writing your C program, you can include files in two ways. The first way is to surround the file you want to include with the angled brackets < and >. This method of inclusion tells the preprocessor to look for the file in the predefined default location. This predefined default location is often an INCLUDE environment variable that denotes the path to your include files. For instance, given the INCLUDE variable
INCLUDE=C:COMPILERINCLUDE;S:SOURCEHEADERS;
using the #include <file> version of file inclusion, the compiler first checks the C:COMPILERINCLUDE
directory for the specified file. If the file is not found there, the compiler then checks the
S:SOURCEHEADERS directory. If the file is still not found, the preprocessor checks the current directory.
 
The second way to include files is to surround the file you want to include with double quotation marks. This
method of inclusion tells the preprocessor to look for the file in the current directory first, then look for it in the predefined locations you have set up. Using the #include “file” version of file inclusion and applying
it to the preceding example, the preprocessor first checks the current directory for the specified file. If the
file is not found in the current directory, the C:COMPILERINCLUDE directory is searched. If the file
is still not found, the preprocessor checks the S:SOURCEHEADERS directory.
The #include <file> method of file inclusion is often used to include standard headers such as stdio.h or
stdlib.h. This is because these headers are rarely (if ever) modified, and they should always be read from your
compiler’s standard include file directory. 
The #include “file” method of file inclusion is often used to include nonstandard header files that you have created for use in your program. This is because these headers are often modified in the current directory, and you will want the preprocessor to use your newly modified version of the header rather than the older, unmodified version.
 
 
 
总的来说:
当用#include“file.h”时,先搜索当前工作目录,如果没有,再去搜索库,库没有再搜索资源库;
当用#include<file.h>时,编译器先从标准库路径开始搜索,如果没再搜索资源库目录,最好搜索当前工作目录。
相关文章
解决办法:error LNK2005: &quot;void * __cdecl operator new(unsigned int)&quot; 已经在 LIBCMTD.lib(new.obj) 中定义
解决办法:error LNK2005: &quot;void * __cdecl operator new(unsigned int)&quot; 已经在 LIBCMTD.lib(new.obj) 中定义
224 0
|
编译器
arm-none-eabi-g++ -Xlinker -T &quot;../LF3Kmonitor.ld&quot; -Xlinker -Map=&quot;Bogota_ICT_V.map&quot;-ram-hosted.ld -mc
1、arm-none-eabi-g++:是编译ARM裸板用的编译器,不依赖于操作系统。 2、-Xlinker -T "../LF3Kmonitor.ld" -Xlinker -Map="Bogota_ICT_V.map"-ram-hosted.ld -mc      使用连接器:-Xlinker -rpath -Xlinker (-Xlinker -rpath=)        第二个-Xlinker作为参数时表示给连接器传参。
1189 0
ICCAVR:cannot include source file "iom16.h"
使用iccv7avrV7.22,ICCAVR编译现成工程报错:   查看ICCAVR安装E:\iccv7avr\include目录,发现没有iom16.h文件,与其最近的是iom16v.h。
1439 0
error LNK2005: &quot;void * __cdecl operator new(unsigned int)&quot; (??2@YAPAXI@Z) 已经在 LIBCMTD.lib(new.obj) 中
在编译文章: 使用GetAdaptersAddresses函数获取物理MAC地址中的代码时,出现以下错误: 错误 1 error LNK2005: “void * __cdecl operator new(unsigned int)” (??2@YAPAXI@Z) 已经在 LIBCMTD.
1086 0
[20120106]Extensibility Types.txt
http://docs.oracle.com/cd/B28359_01/appdev.111/b28425/ext_types_ref.htm例子:SQL> column text format a20SQL> select column_value text from table (sys.
650 0
|
SQL 索引 Shell
[20111215]sys.col_usage$和intcol# = 1001的问题.txt
[20111215]sys.col_usage$和intcol# = 1001的问题.txt讨论链接:http://www.itpub.net/thread-1454515-1-1.htmlcol_usage$字典基表,其目的在于监控column在SQL语句作为predicate的情况,col_usage$的出现完善了CBO中柱状图自动收集的机制。
863 0