Tips and Tricks (13)

Previous T&T

Reaching the limits of Arduino…


Issue 523: Include new/delete operators to complement the existing malloc/free

“Because avr-gcc only provides libc and not libc++ it doesn’t provide the new and delete operators. This means that if you want to write C++ code that uses the heap you’ll run into linker errors and have to provide your own new and delete.

It could be that this is deliberate to discourage beginners from putting objects onto the heap – given the limited memory on Arduino, and that it’s easy for beginners to introduce memory leaks, I can see the benefit in this.

However, we have got malloc/free, which means that people can use the heap, so I’m not sure this is a deliberate decision or historical accident.”

Too bad!


Next Tip & Trick

Leave a Reply

You must be logged in to post a comment.