8

Possible Duplicate:
What is the difference between #include <filename> and #include “filename”?
Difference between writing #import <filename.h> and #import “filename.h” i.e written the file name in angular brackets and quotes?

This might be a stupid question. What is the difference between #import <QuartzCore/QuartzCore.h> and #import "QuartzCore/QuartzCore.h"? (greater-than/less-than vs the double-quotes)

They both seem to work.

Community
  • 1
  • 1
pixelfreak
  • 17,714
  • 12
  • 90
  • 109
  • repeat of this question: http://stackoverflow.com/questions/3156432/difference-between-writing-import-filename-h-and-import-filename-h-i-e-wri – TomSwift Dec 07 '11 at 23:37
  • Ah, was having trouble finding those questions. Please close as duplicate. – pixelfreak Dec 08 '11 at 00:08
  • That's duplicate. Follow this one : http://stackoverflow.com/questions/3162030/difference-between-angle-bracket-and-double-quotes-while-including-heade – Jayprakash Dubey Sep 12 '13 at 06:33

2 Answers2

12

In general the #import "QuartzCore/QuartzCore.h" form is "find my very own header, if you can't find it look for a system header", and the <QuartzCore/QuartzCore.h> form is "find a system header". In theory the locations are compiler defined and they could be implemented differently on a given platform, but I haven't run into a C compiler that does anything different.

Stripes
  • 4,161
  • 2
  • 25
  • 29
  • the `#import "QuartzCore/QuartzCore.h"` doesn't look for a system header. its xCode that imports frameworks to local headers. – Daniel Dec 07 '11 at 23:48
  • 1
    The double quote version looks for system headers if local ones are not found, that is why he said "They both seem to work". (there is a build setting to make <> search user paths first, but I didn't figure it was all that important for this question) -- try #include "stdio.h" it'll find it. – Stripes Dec 08 '11 at 00:02
-2

#include <something> tells the compiler to look in all include directories.
#include "something" tells the compiler to look only in the directory of the file with the include in it.

Daniel
  • 30,896
  • 18
  • 85
  • 139
  • 2
    Not correct. The standard explicitly states that if the normal search for `#include "something"` fails, it is reprocessed as though it said `#include `. So it is more correct to say that the quoted version looks in the same directory *first*, but then looks in all the include directories. – rdb Nov 11 '18 at 11:19