Is there any specific reason for using either of the options as they both compile, or are they effectively interpreted exactly the same way by the compiler, what is the preferred / best option and why ??
I was recently requested to add some documentation about this to the #include page of the Arduino Language reference. This is what I have proposed:
**LibraryFile.h**: when the angle brackets syntax is used, the libraries paths will be searched for the file. +
**LocalFile.h**: When the double quotes syntax is used, the folder of the file using the `#include` directive will be searched for the specified file, then the libraries paths if it was not found in the local path. Use this syntax for header files in the sketch's folder.
Within the context of the rest of the reference page, does that explanation make it clear to you? If not, please let me know what you find to be confusing or if you have any ideas for improvement.
I have noticed that when < > are used, then the name of the include file is highlighted in red by the IDE so it obviously recognises that they are different.
Yes, but not in any way specific to #include. Library authors may define keywords of the library. The Arduino IDE highlights occurrences of all keywords defined by all installed libraries whenever they occur in the sketch code. However, it does not do this for strings. The quoted “SoftwareSerial.h” is a string, which the version surrouded by angle brackets <SoftwareSerial.h> is not.
In general, this highlighting of the header filename is purely a side effect of the common practice of the class name being the same as the header filename that contains its declaration. The library author’s intent was for the class name to be a keyword, not the filename. You will find that the header filenames of libraries aren’t always highlighted as keywords by the IDE, so don’t place much importance on the colors of things in the Arduino IDE. What’s important is what the compiler thinks of the code, and the compiler doesn’t know anything about the arbitrary keywords definition system. That’s purely cosmetic.