Objective-C中import和include之间的区别是什么? [重复]

时间:2021-07-21 00:10:54

Possible Duplicate:
What is the difference between #import and #include in Objective-C?

可能重复:Objective-C中#import和#include有什么区别?

It seems both can work when I use import or include in Objective-C, what's the difference between those two?

当我使用import或包含在Objective-C中时,它们似乎都可以工作,这两者之间有什么区别?

1 个解决方案

#1


2  

..#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.
  • #include允许您多次包含同一文件。
  • #import ensures that the preprocessor only includes a file once.
  • #import确保预处理器只包含一次文件。

C programmers tend to use #include. Objective-C programmers tend to user #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. Preprocessor directives start with #. The three most popular are

在Objective-C中编译文件分两次完成。首先,预处理器运行该文件。预处理器的输出进入真正的编译器。预处理程序指令以#开头。三个最受欢迎的是

-#include

-#包括

-#import

-#进口

-#define

- #定义

#1


2  

..#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.
  • #include允许您多次包含同一文件。
  • #import ensures that the preprocessor only includes a file once.
  • #import确保预处理器只包含一次文件。

C programmers tend to use #include. Objective-C programmers tend to user #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. Preprocessor directives start with #. The three most popular are

在Objective-C中编译文件分两次完成。首先,预处理器运行该文件。预处理器的输出进入真正的编译器。预处理程序指令以#开头。三个最受欢迎的是

-#include

-#包括

-#import

-#进口

-#define

- #定义