-1

Hey all I am wondering if it's possible to modify the WString.cpp file to only include the commands that I need for my project since that file is so large.

I am using a Digispark arduino that is Attiny85 which only has about 6k flash memory after bootloader.

Needless to say I am almost out of flash memory and I still need to do a few things.

I am reading from a serial port (in this case, using DigiCDC for a virtual serial port).

How can I overwrite the default Strings class that looks like its built in to the IDE with my own modified String class so I can get a smaller footprint?

Thanks!

StealthRT
  • 259
  • 2
  • 8
  • 16

1 Answers1

1

You can make a copy of WString.cpp, edit it, and add it to your project. Note however that:

  1. You will have to define every method that you use. Otherwise the linker will pull WString.o from the Arduino core library in order to resolve the missing methods, and then it will complain that some methods have been defined twice.
  2. Just pruning WString.cpp from unused methods will not help: the linker is already doing that for you.
  3. To know which functions/methods of your program are taking too much flash, you can use the command avr-nm --size-sort -Crtd program.elf.
  4. I second Majenko in recommending against String objects if possible.
Edgar Bonet
  • 45,094
  • 4
  • 42
  • 81