diff --git a/libraries/I2S/src/I2S.cpp b/libraries/I2S/src/I2S.cpp index 00837e202..2628d5870 100644 --- a/libraries/I2S/src/I2S.cpp +++ b/libraries/I2S/src/I2S.cpp @@ -38,9 +38,20 @@ static I2SDevice_SAMD21G18x i2sd(*I2S); #include "I2S.h" #ifdef USE_TINYUSB -// For Serial when selecting TinyUSB +// For Serial when selecting TinyUSB (also causes the Arduino builder to link +// the TinyUSB library). Outside PlatformIO this include must stay plain and +// unconditional: the Arduino builder discovers the library from it, and its +// dependency-detection pass cannot parse a __has_include() expression. +#ifdef PLATFORMIO +// PlatformIO does not give framework-bundled libraries the lib_deps include +// paths, so the header can be unreachable here; skip it instead of failing. +#if !defined(__has_include) || __has_include() #include #endif +#else +#include +#endif +#endif int I2SClass::_beginCount = 0; diff --git a/libraries/SAMD_AnalogCorrection/src/SAMD_AnalogCorrection.cpp b/libraries/SAMD_AnalogCorrection/src/SAMD_AnalogCorrection.cpp index e39ab43e3..7deeaf0bd 100644 --- a/libraries/SAMD_AnalogCorrection/src/SAMD_AnalogCorrection.cpp +++ b/libraries/SAMD_AnalogCorrection/src/SAMD_AnalogCorrection.cpp @@ -20,9 +20,20 @@ #include "SAMD_AnalogCorrection.h" #ifdef USE_TINYUSB -// For Serial when selecting TinyUSB +// For Serial when selecting TinyUSB (also causes the Arduino builder to link +// the TinyUSB library). Outside PlatformIO this include must stay plain and +// unconditional: the Arduino builder discovers the library from it, and its +// dependency-detection pass cannot parse a __has_include() expression. +#ifdef PLATFORMIO +// PlatformIO does not give framework-bundled libraries the lib_deps include +// paths, so the header can be unreachable here; skip it instead of failing. +#if !defined(__has_include) || __has_include() #include #endif +#else +#include +#endif +#endif void analogReadCorrection (int offset, uint16_t gain) { diff --git a/libraries/SPI/SPI.cpp b/libraries/SPI/SPI.cpp index 0393752d7..42c0564d5 100644 --- a/libraries/SPI/SPI.cpp +++ b/libraries/SPI/SPI.cpp @@ -23,9 +23,20 @@ #include #ifdef USE_TINYUSB -// For Serial when selecting TinyUSB +// For Serial when selecting TinyUSB (also causes the Arduino builder to link +// the TinyUSB library). Outside PlatformIO this include must stay plain and +// unconditional: the Arduino builder discovers the library from it, and its +// dependency-detection pass cannot parse a __has_include() expression. +#ifdef PLATFORMIO +// PlatformIO does not give framework-bundled libraries the lib_deps include +// paths, so the header can be unreachable here; skip it instead of failing. +#if !defined(__has_include) || __has_include() #include #endif +#else +#include +#endif +#endif #define SPI_IMODE_NONE 0 #define SPI_IMODE_EXTINT 1 diff --git a/libraries/Servo/src/samd/Servo.cpp b/libraries/Servo/src/samd/Servo.cpp index ba07e70a7..5cf289978 100644 --- a/libraries/Servo/src/samd/Servo.cpp +++ b/libraries/Servo/src/samd/Servo.cpp @@ -22,9 +22,20 @@ #include #ifdef USE_TINYUSB -// For Serial when selecting TinyUSB +// For Serial when selecting TinyUSB (also causes the Arduino builder to link +// the TinyUSB library). Outside PlatformIO this include must stay plain and +// unconditional: the Arduino builder discovers the library from it, and its +// dependency-detection pass cannot parse a __has_include() expression. +#ifdef PLATFORMIO +// PlatformIO does not give framework-bundled libraries the lib_deps include +// paths, so the header can be unreachable here; skip it instead of failing. +#if !defined(__has_include) || __has_include() #include #endif +#else +#include +#endif +#endif #if defined(__SAMD51__) // Different prescalers depending on FCPU (avoid overflowing 16-bit counter) diff --git a/libraries/Wire/Wire.cpp b/libraries/Wire/Wire.cpp index da9732c59..f79ad0038 100644 --- a/libraries/Wire/Wire.cpp +++ b/libraries/Wire/Wire.cpp @@ -25,9 +25,20 @@ extern "C" { #include #ifdef USE_TINYUSB -// For Serial when selecting TinyUSB +// For Serial when selecting TinyUSB (also causes the Arduino builder to link +// the TinyUSB library). Outside PlatformIO this include must stay plain and +// unconditional: the Arduino builder discovers the library from it, and its +// dependency-detection pass cannot parse a __has_include() expression. +#ifdef PLATFORMIO +// PlatformIO does not give framework-bundled libraries the lib_deps include +// paths, so the header can be unreachable here; skip it instead of failing. +#if !defined(__has_include) || __has_include() #include #endif +#else +#include +#endif +#endif #include "Wire.h"