6 ms·
I took a brief skim through so apologies if I missed that it was mentioned, but wanted to bring up the Embedded Template Library[0]. The (over)simplified concep
by embeng4096 6mo ago
I took a brief skim through so apologies if I missed that it was mentioned, but wanted to bring up the Embedded Template Library[0]. The (over)simplified concept is: it provides a statically-allocated subset (but large subset) of the C++ standard library for use in embedded systems. I used it recently in a C++ embedded project for statically-allocated container/list types, and for parsing strings, and the experience was nice.
[0]: https://www.etlcpp.com/ https://www.etlcpp.com/
- maldev 6mo agoSo I use C++ heavily in the kernel. But couldn't you just set your own allocator and a couple other things and achieve the same effect and use the actual C++ STL? In kernel land, at the risk of simplifying, you just implement allocators and deallocators and it "just works", even on c++ 26.
- nly 6mo agoDo you typically just compile with -fno-rtti -fno-exceptions -nostdlib ? Last time I did embedded work this was basically all that was required.
- nulltrace 6mo agoThose three flags cover most of it. One gotcha: -fno-exceptions makes `new` return nullptr instead of throwing, so if any library code expects exceptions you get silent corruption. We added -fcheck-new to catch that. Also -nostdlib means no global constructors run, so static objects with nontrivial ctors need you to call __libc_init_array yourself.