Maybe this is unrelated to Freddie's the issue, but I have recently tried to use __has_include in one of my libraries and spent a log time trying to make it work. The code was something like this:
VSCode's C/C++ extension was highlighting the text to show that __has_include was behaving as expected. In other words, when “myHeaderFile.h” was available, the code in #include “myHeaderFile.h” was active, lit. When I removed “myHeaderFile.h”, that section of the code that included “myHeaderFile.h” was inactive, grayed out. Furthermore, by right-clicking on “myHeaderFile.h”, it was possible to click on the “Go to Definition” button, which took me directly to the “myHeaderFile.h” file. This combination of factors misled me into believing that __has_include was working as expected and was able to find the path to my header file.
However, the reality is that during the compilation of the project, “myHeaderFile.h” was never included, regardless of whether it existed or not. After many attempts, I had to change the include and __has_include to the full path to “myHeaderFile.h” starting from the current file. The code looks like this:
The solution is not elegant, as it depends on the current folder structure of the project. But just for the sake of testing, try to use the full path of SD.h and USBHost_t36.h to see if it makes any difference.
C++:
#if defined(__has_include)
#if __has_include("myHeaderFile.h") // Checks if the header file exists and can be included
#include "myHeaderFile.h" // Includes the header file. Header file is located inside src/ folder of this PlatformIO project
#endif
#endif
VSCode's C/C++ extension was highlighting the text to show that __has_include was behaving as expected. In other words, when “myHeaderFile.h” was available, the code in #include “myHeaderFile.h” was active, lit. When I removed “myHeaderFile.h”, that section of the code that included “myHeaderFile.h” was inactive, grayed out. Furthermore, by right-clicking on “myHeaderFile.h”, it was possible to click on the “Go to Definition” button, which took me directly to the “myHeaderFile.h” file. This combination of factors misled me into believing that __has_include was working as expected and was able to find the path to my header file.
However, the reality is that during the compilation of the project, “myHeaderFile.h” was never included, regardless of whether it existed or not. After many attempts, I had to change the include and __has_include to the full path to “myHeaderFile.h” starting from the current file. The code looks like this:
C++:
#if defined(__has_include)
#if __has_include("../../src/myHeaderFile.h")
#include "../../src/myHeaderFile.h"
#endif
#endif
The solution is not elegant, as it depends on the current folder structure of the project. But just for the sake of testing, try to use the full path of SD.h and USBHost_t36.h to see if it makes any difference.