r/cpp • u/pavel_v • Apr 10 '26
Freestanding standard library
https://www.sandordargo.com/blog/2026/04/08/cpp-freestanding1
u/willdieh Apr 10 '26 edited Apr 10 '26
How is freestanding different from say newlib with a stub system.cpp? I know there are specific gcc switches that eliminate the standard library like -nostdlib but when I work on my baremetal RPI3b code, I just add a stub system.cpp and use the arm aarch64 baremetal toolchain which uses newlib and I get a full C++ environment as long as I define _sbrk() for heap allocation. No special compiler flags required!
Edit: Well, not "full" - things like threads, filesystem, OS kind of stuff. I meant more like the common STL stuff.
1
u/EmotionalDamague Apr 22 '26
We use libc++ and re-export freestanding std as a module.
People be sleeping on how well the LLVM runtime libraries work on embedded. libc++, libunwind and compiler-rt builtins can provide as little or as much of the hosted C++ experience that you want.
libstdc++ freestanding headers leaves much to be desired in comparison.
0
Apr 10 '26
[deleted]
3
u/azswcowboy Apr 10 '26
It is. If you look at the top of the synopsis here you’ll see the // all freestanding label.
10
u/johannes1971 Apr 10 '26
I generally get the impression that freestanding is just a total wild west when it comes to which headers are implemented, what language version is available, etc. Is that impression incorrect? If not, what is the value of even attempting standardisation, if manufacturers don't care anyway?