proper way to override functions in the distribution library

Status
Not open for further replies.

vladn

Well-known member
For my project I had to modify the Teensy Audio library - 2 new .cpp/.h pairs added, 6 existing files modified. Before I did it the brute force way - inside the distribution Audio library. Would it work if I create a new library in the home directory instead, called "Audio_mods" with the appropriate Audio_mods.h file, then add my new files and copy files from the system Audio library that I need to modify ? I would include "Audio_mods.h" and "Audio.h" in my project file. Would it pick the modded files (same file names) from the local library instead of the distribution library ? How the library file selection priority works in Arduino ?
 
I did not find a satisfactory way to keep the changed part of the Audio library separately. It compiles ok but confuses the linker.

The best I can do is to make a copy of the entire Audio library in the user library directory, change the name of the library and the top header file to "Audio_modified", merge my mods, then include the "Audio_modified.h" instead of "Audio.h" header into my project.
 
i dont think the name has to be changed as long as it's in the same sketch folder, it's rprioritized over other sketches of "same name"
I tested this with AsyncUDP for ESP8266 in my libraries folder, and modified a special version for Teensy keeping the same H/CPP file names in the sketch folder.
This allowed me to flash the ESP using original library, and flash teensy with the modified library. This also leaves the original library updatable (for ESP) while the teensy one is untouched.
 
i dont think the name has to be changed as long as it's in the same sketch folder, it's prioritized over other sketches of "same name"
That is my experience also. I've tried to go another step - keep only the changed/added files in the local folder, but unfortunately it did not work. Keeping a full copy is not a big deal for small distribution libraries, but for something as big as the "Audio" keeping track of the changes and merging with latest version is inconvenient, hence I've tried to keep only the modified/added files in a local directory. After few unsuccessful tries I gave up on that idea and just have a copy of the entire "Audio" distribution lib in the local project holder. Name change is most likely not required, but I do it for reminding myself that the library is modified.
 
Status
Not open for further replies.
Back
Top