简体   繁体   中英

What's the difference between these imports?

For example, sometimes there's an import like this:

#import <Cocoa/Cocoa.h>

and sometimes the import looks like this:

#import "Foo.h"

Now what's the difference there? The first is in < > tag things, and the second is in doublequotes. What does the first do? Is that used for pre-compiled files like frameworks which are compiled already? Or what's the point there?

The angle brackets indicate system includes (which looks in a different set of directories).

The double-quoted include is for non-system includes... (ie yours). It will look in the current directory first, and then other (command line specified) include directories.

There's a pretty good set of documentation here:

http://developer.apple.com/mac/library/documentation/DeveloperTools/gcc-4.0.1/cpp/Header-Files.html

The general idea is that the angle bracket form looks in your path and in your lib and in any additional include directories that you tell it, while the quote form looks relative to the including file.

EG for Visual C++

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM