Library discovery broken by use of __has_include()
preprocessor operator
#1782
Labels
conclusion: off topic
Off topic for this repository
type: imperfection
Perceived defect in any part of project
Describe the problem
Suppose I have a library I am working on, in this case MTP_Teensy (in this case: https://github.com/KurtE/MTP_Teensy/tree/try_auto_detect_sd_media)
Where I would like to detect if the sketch is using the SD library and if so I define an override to a method.
In the library header file, I have:
And if it is included:
Now I have real simple sketch using it:
End of the compile output.
However if I swap the order of the two includes, that is:
This will not build. In fact SD.h will not loaded:
The build output showed a few hints. When the build succeeded, the list of libraries at the end showed:
The failed version only only showed:
Using library MTP_Teensy at version 1.0.0 in folder: C:\Users\kurte\Documents\Arduino\libraries\MTP_Teensy
Also looking that the compile commands at the -I we see in the one that worked
The one that failed:
So the search path did not find the SD.h file so the __has_include(<SD.h>)
was false... Also was not found in main sketch so we then get the compile errors
To reproduce
More or less covered above.
I have RC8 of the IDE installed.
I have the current Teensy boards installed: https://www.pjrc.com/teensy/td_156/package_teensy_index.json
I have the MTP_Teensy installed.
Expected behavior
Should build with includes in either order
Arduino CLI version
Arduino IDE2 RC8 - just downloaded
Operating system
Windows
Operating system version
Windows 10
Additional context
More comments up on the Teensy forum thread I opened yesterday:
https://forum.pjrc.com/threads/70526-__has_include(-lt-SD-h-gt-)-how-is-it-supposed-to-work
Fails the same way on 1.8.19 currently Teensyduino release
Sort of related to: #1650
Issue checklist
The text was updated successfully, but these errors were encountered: