newdigate / teensy-variable-playback

Firmware library: variable playback rate for teensy audio library
MIT License
54 stars 7 forks source link

Why overridding std function defs in examples? #59

Closed samzmann closed 5 months ago

samzmann commented 5 months ago

Some of the examples have this code at the bottom:

namespace std
{
  void __throw_bad_function_call() {}
  void __throw_length_error(char const *) {}
}

This causes my build to fail with this error:

Linking .pio/build/teensy41/firmware.elf
/Users/sam/.platformio/packages/toolchain-gccarmnoneeabi-teensy/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /Users/sam/.platformio/packages/toolchain-gccarmnoneeabi-teensy/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+dp/hard/libstdc++.a(functexcept.o): in function `std::__throw_length_error(char const*)':
(.text.unlikely._ZSt20__throw_length_errorPKc+0x0): multiple definition of `std::__throw_length_error(char const*)'; .pio/build/teensy41/src/main.cpp.o:main.cpp:(.text.unlikely._ZSt20__throw_length_errorPKc+0x0): first defined here
collect2: error: ld returned 1 exit status
*** [.pio/build/teensy41/firmware.elf] Error 1

To fix my build, I had to change all my uses of std::string to char. Then I realized I could just delete the above lines and all seemed fine. So what is the purpose of these overrides???

newdigate commented 5 months ago

Just delete the two lines. there was once a time before std was standard in teensyduino. Blah blah

samzmann commented 5 months ago

Hi Nic, thanks for you super quick answer! I'll mark this issue as closed.