#import versus #include

Objective-C introduced a new way to reference header files. Traditionally, a #include statement would literally drop in the header file of a respective file into a location indicated by the compiler directive #include. This would be akin to inserting the contents of the header file into each and every #include reference. The reference table and linker would then be responsible to ensure that the correct references and functions are associated with the final compiled program.

Apple, always thinking differently for things like changing boolean logic to Yes and No, created the #import compiler directive. #import is supposed to be a smarter way to reference header files in order to prevent redundant or recursive header files.

However, there are already precautions in C for redundancy. Normally in basic C guard directives are added to header files such as:

Comments are closed.

Search

Websites

  • slide
  • slide
  • slide
  • slide