MTP Problem

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:
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.
 
If you are talking about Arduino IDE builds. There are issues with the has include...
There was an issue I created a long time ago, that then was moved to the CLI...


That is if your sketch has something like:
Code:
#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
It won't include it, even if it exists. Why? The pre-parser code to find library dependencies, uses compiler preprocessor to get
a list of directories with the libraries. This won't include the directory which actually has your header file, so when
it generates the build command, that directory will not be included in the -I of the compile commands and as such
the compiler says, nope it does not exist along any of the included directories...
 
MTP worked for me back in January, but I had the same issue with the EEPROM include starting today in PlatformIO. Setting `lib_ldf_mode = deep` in `platformio.ini` solved the issue for me.

Has anyone tested whether this is still needed with teensyduino 1.60? Looks like there's a RC with PlatformIO install instructions here.
 
Has anyone tested whether this is still needed with teensyduino 1.60? Looks like there's a RC with PlatformIO install instructions her
I tested 1.60 with PlatformIO (manually), and the original branch of MTP_Teensy still requires setting the LDF mode to deep. It is no longer needed with pauls_branch. This branch compiles well with 1.60 (with just two unused variables warnings easily ignored).
 
Back
Top