Go Down

Topic: Arduino Due warning: std::__throw_length_error(char const*) (Read 2539 times) previous topic - next topic

neltnerb

Apr 30, 2015, 08:37 pm Last Edit: Apr 30, 2015, 08:37 pm by Brian Neltner
I'm writing some libraries for the Arduino Due which uses vectors of bytes passed to classes defined in header files. It then uses that byte vector as data to send to various peripherals via SPI, so I want to use this technique in order to send arbitrary length data packets.

It's throwing a warning, but I'm not sure what it means. It's still compiling, but I like to not have warnings if I can help it, especially since I don't know what they mean.

(home directory path and file names redacted)
Code: [Select]
In function `std::vector<unsigned char, std::allocator<unsigned char> >::_M_check_len(unsigned int, char const*) const':
/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/arm-none-eabi/include/c++/4.8.3/bits/stl_vector.h:1339: warning: undefined reference to `std::__throw_length_error(char const*)'


Anyone have any clues? I'm using Arduino 1.6.3, is the library directory wrong? This is on linux, and it's looking in the ~/.arduino15 library for the stl_vector.h file, is that incorrect perhaps?

ellbur

Hi Brian,

I was just searching around for this warning, because apparently in more recent versions of Arduino (or possibly ARM gcc, or the ARM STL libraries...) it has become an error.

I couldn't find a solution online, but I worked around it by doing:

Code: [Select]

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


ie, by defining a dummy throw function that does nothing. Assuming that you never actually have any length errors, the function will never be called, so there will be no problems.

The reason for this error is that the code is compiled without support for C++ exceptions.

Best,
Owen

edringel

I came upon your answer while trying to solve a problem similar to the one in question. You saved me HOURS! Thank you.
Ed

Go Up