Freestanding C++ standard library
1 points by raymii
1 points by raymii
I’ve never worked with an embedded system that didn’t support heap allocation! The freestanding library sounds lower level than the libraries in ESP32 or ARM Cortex SDKs. Are people using C++ on 8-bit microcontrollers?
The problem isn't so much that there's no heap allocation, it's that embedded heap allocators often have different constraints. Most embedded systems turn off exception handling (which the standard still likes to pretend doesn't happen) and allocation failures are common. This means that the normal C++ standard library thing of 'if allocation fails and you don't have exceptions turned on, abort' doesn't work at all.
There are also things like wanting timeouts on allocator calls and passing custom pools that are really hard with a load of standard-library things, so using something like std::vector in an embedded OS is painful (we support it, we just don't recommend it because it will likely die in horrible ways).
Unfortunately, std::atomic::notify* were added to freestanding and these are really, really bad APIs that are painful to make work on embedded systems.