Possible Duplicate:
What is the difference between #import and #include in Objective-C?可能重复:Objective-C中#import和#include有什么区别?
What is the difference between
有什么区别
#include< >
#include" "
#import< >
#import" "
4 个解决方案
#1
13
The #import
directive is an improved version of #include
. #import
ensures that a file is only ever included once so that you never have a problem with recursive includes.
#import指令是#include的改进版本。 #import确保文件只被包含一次,这样你就不会有递归包含的问题。
#import ""
first check the header in project folder then goes to system library, and the #import<>
checks for system headers". In theory the locations are compiler defined and they could be implemented differently on a given platform.
#import“”首先检查项目文件夹中的标题,然后转到系统库,#import <>检查系统标题“。理论上,这些位置是编译器定义的,它们可以在给定平台上以不同方式实现。
#2
3
When using #import
, the header include guard is unnecessary. Otherwise, it's just like #include
.
使用#import时,标题包含guard是不必要的。否则,就像#include一样。
The header include guard, seen in C and C++ files:
标题包括guard,在C和C ++文件中看到:
#ifndef HGUARD_MONHeader_h
#define HGUARD_MONHeader_h
...header contents...
#endif
#3
3
import is super set of include, it make sure file is included only once. this save you from recursive inclusion. about "" and <>. "" search in local directory and <> is use for system files.
import是超级包含的,它确保文件只包含一次。这可以节省您的递归包含。关于“”和<>。 “”在本地目录中搜索,<>用于系统文件。
#4
2
The #import directive was added to Objective-C as an improved version of #include. Whether or not it's improved, however, is still a matter of debate. #import ensures that a file is only ever included once so that you never have a problem with recursive includes. However, most decent header files protect themselves against this anyway, so it's not really that much of a benefit.
#import指令作为#include的改进版本添加到Objective-C中。然而,它是否得到改善仍然是一个争论的问题。 #import确保文件只被包含一次,这样你就不会有递归包含的问题。但是,大多数体面的头文件都可以保护自己不受此影响,所以它并没有那么大的好处。
What is the difference between #import and #include in Objective-C? :
Objective-C中#import和#include有什么区别? :
#include and #import request that the preprocessor* read a file and add it to its output. The difference between #include and #import is that
#include和#import请求预处理器*读取文件并将其添加到其输出中。 #include和#import之间的区别在于
#include allow you to include the same file many times. #import ensures that the preprocessor only includes a file once. C programmers tend to use #include. Objective-C programmers tend to use #import.
#include允许您多次包含同一文件。 #import确保预处理器只包含一次文件。 C程序员倾向于使用#include。 Objective-C程序员倾向于使用#import。
* Compiling a file in Objective-C is done in two passes. First,
the preprocessor runs through the file. The output from the preprocessor goes into the real compiler.*在Objective-C中编译文件分两次完成。首先,预处理器运行该文件。预处理器的输出进入真正的编译器。
#1
13
The #import
directive is an improved version of #include
. #import
ensures that a file is only ever included once so that you never have a problem with recursive includes.
#import指令是#include的改进版本。 #import确保文件只被包含一次,这样你就不会有递归包含的问题。
#import ""
first check the header in project folder then goes to system library, and the #import<>
checks for system headers". In theory the locations are compiler defined and they could be implemented differently on a given platform.
#import“”首先检查项目文件夹中的标题,然后转到系统库,#import <>检查系统标题“。理论上,这些位置是编译器定义的,它们可以在给定平台上以不同方式实现。
#2
3
When using #import
, the header include guard is unnecessary. Otherwise, it's just like #include
.
使用#import时,标题包含guard是不必要的。否则,就像#include一样。
The header include guard, seen in C and C++ files:
标题包括guard,在C和C ++文件中看到:
#ifndef HGUARD_MONHeader_h
#define HGUARD_MONHeader_h
...header contents...
#endif
#3
3
import is super set of include, it make sure file is included only once. this save you from recursive inclusion. about "" and <>. "" search in local directory and <> is use for system files.
import是超级包含的,它确保文件只包含一次。这可以节省您的递归包含。关于“”和<>。 “”在本地目录中搜索,<>用于系统文件。
#4
2
The #import directive was added to Objective-C as an improved version of #include. Whether or not it's improved, however, is still a matter of debate. #import ensures that a file is only ever included once so that you never have a problem with recursive includes. However, most decent header files protect themselves against this anyway, so it's not really that much of a benefit.
#import指令作为#include的改进版本添加到Objective-C中。然而,它是否得到改善仍然是一个争论的问题。 #import确保文件只被包含一次,这样你就不会有递归包含的问题。但是,大多数体面的头文件都可以保护自己不受此影响,所以它并没有那么大的好处。
What is the difference between #import and #include in Objective-C? :
Objective-C中#import和#include有什么区别? :
#include and #import request that the preprocessor* read a file and add it to its output. The difference between #include and #import is that
#include和#import请求预处理器*读取文件并将其添加到其输出中。 #include和#import之间的区别在于
#include allow you to include the same file many times. #import ensures that the preprocessor only includes a file once. C programmers tend to use #include. Objective-C programmers tend to use #import.
#include允许您多次包含同一文件。 #import确保预处理器只包含一次文件。 C程序员倾向于使用#include。 Objective-C程序员倾向于使用#import。
* Compiling a file in Objective-C is done in two passes. First,
the preprocessor runs through the file. The output from the preprocessor goes into the real compiler.*在Objective-C中编译文件分两次完成。首先,预处理器运行该文件。预处理器的输出进入真正的编译器。