h4yn0nnym0u5e
Well-known member
This could be the shortest piece of code posted under the Forum Rule ever:
I could have made it shorter, but that would have been silly. And it really is the complete source code.
So. I've compiled the above for Teensy 3.5, with various USB types and the #include lines commented out or not, depending. Arduino 1.8.15, Teensyduino 1.56. Code and global variable sizes come out as follows.
The problem is the code size bloat which adds 34k when SD.h is just mentioned. I don't even have to use it (as you see - I'm not using anything...), but it seems to result in pulling in SDFile, SDClass, SPIClass, ExFat, Fat, SdSpiCard, SdioCard, etc. etc., and the link optimisation for some reason isn't eliminating them right back out when it finds they're not used. You can't say "just don't include it when you're not using it", because Audio.h has a nested #include. 34k isn't a major loss for the larger Teensies, but for the LC it's about 50% of the total code space.
Short of the author fixing the SD library to make it behave properly, does anyone have an idea how to eliminate this?
Code:
#include "Audio.h"
//#include "SD.h"
void setup() {}
void loop() {}
So. I've compiled the above for Teensy 3.5, with various USB types and the #include lines commented out or not, depending. Arduino 1.8.15, Teensyduino 1.56. Code and global variable sizes come out as follows.
#includes | USB | Code | variables | Comment |
---|---|---|---|---|
None | Serial | 7032 | 3020 | |
None | Serial+MIDI+Audio | 13568 | 6472 | |
SD.h | Serial+MIDI+Audio | 48440 | 7916 | |
Audio.h | Serial+MIDI+Audio | 50424 | 9004 | dynamic audio |
Audio.h | Serial+MIDI+Audio | 50552 | 9004 | TD1.56 audio |
Short of the author fixing the SD library to make it behave properly, does anyone have an idea how to eliminate this?