Including SPI.h is very strange

Can someone please explain this odd behaviour

Adding #include "SPI.h" to my source tells me there is no such file - even though the SPI.h file is present on my PC in arduino/hardware/arduino/avr/libraries/SPI and arduino/hardware/arduino/sam/libraries/SPI (plus a few other places)

However if I go to Sketch > Import Ligrary > SPI this now adds the line

#include <SPI.h> and my source now compiles

Why does the library file now suddenly exist?
What is the difference between #include "SPI.h" and #include <SPI.h>?

Things get wierder... I can now edit this #include <SPI.h> to #include "SPI.h" and will now compile. But that is just the #include line I had in the first place

Ahh I thought maybe the Import Library copied smoething to my sketch folder.... So I tried to compile another sketch I just happened to have open and just added the line #include "SPI.h" (without having to do the sketch > import library > SPI that sketch also compiles without error!

Can anyone please explain this wierd behaviour?

cheers

The difference between the two is supposed to be:

#include <...>
Include a file from any one of the system or command line (-I...) specified include locations.

#include "..."
Include a file from the same directory or relative to the same directory as the source file.

This is not what the Arduino does though as the IDE fudges so much stuff it's unbelievable.

One of the first things it does is scan your sketch for #include statements and then looks in the libraries folders for those include files, gathering gathering it all together for compilation. As it then compiles everything from the one directory there is now no distinction between "" and <>.

As for why "" didn't work, but <> did, and then changing it to "" did, all I can guess is that you mis-typed something, or included an extra space between the "" or something.