Define default #include directives in library metadata #322
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When a library is selected from the Sketch > Include Library menu of the Arduino IDE,
#include
directives for its header files are added to the sketch.By default,
#include
directives for all header files present in the library's root source folder are added. In some cases that is not wanted. For this reason, the Arduino IDE allows the customization of the behavior of this IDE feature via theincludes
field of thelibrary.properties
library metadata file. When this field is defined, the IDE will instead add#include
directives for only the files in this comma-separated list:https://arduino.github.io/arduino-cli/latest/library-specification/#libraryproperties-file-format
"Adafruit NeoPixel" is a library where the default behavior of the Arduino IDE is not appropriate. The reason is the presence of the
rp2040_pio.h
header in the root source folder. This file contains code specific to the RP2040, and so adding an#include
directive for it will result in a compilation error when a board of any other architecture is selected:https://forum.arduino.cc/t/hardware-pio-h-error/992695
Since the primary
Adafruit_NeoPixel.h
header contains a conditional#include
for that file, there is never a need for the user to have an#include
directive for the file added to their sketch along with the one forAdafruit_NeoPixel.h
. Correct behavior of the Arduino IDE's "Include Library" feature will be ensured by specifyingAdafruit_NeoPixel.h
in theincludes
field oflibrary.properties
.