Learn Effective C++ for Embedded Code
luckyresistor.me
luckyresistor.me
Oh, and the book is free: https://www.state-machine.com/psicc2
I get templates, classes, and constexpr might be incredibly valuable though. If used within reason to avoid code size issues.
Has anyone spent serious time writing large firmwares in c++ with teams? What’s debugging like? How do people agree on what subset of the language and it’s plethora of features to use?
I'm having some fun with RP2040s and ESP32s these days and I can just use standard C++20 as understood by GCC 12 without specific restrictions except exceptions (and I'm having a lot of fun with it) - hell, there's even some boost:: usage in there.
Classes are unambiguously good, but polymorphism (specifically vtables) are controversial. Templating is great, but folk love to complain about code size in abstract to sound smart.
Dynamic memory allocations in general are forbidden, but in practice it's occasionally easier to just support it in some very limited way, and then lock the API down very tightly.
In my experience you normally disable exceptions when working on embedded code. No RTTI either.
> What’s debugging like?
What's with debugging? Not different to C at all.
> How do people agree on what subset of the language and it’s plethora of features to use?
You agree on the language standard to use, you don't pull dependencies arbitrarily and you keep an eye on the code size and memory usage. Some things might go into project style guide which is a nice thing to have anyway.
The movers and shakers in the embedded C++ world are looking at Rust though.
That doesn't mean everyone is looking at it. Like I said, embedded is conservative, so it will be a while before everyone looks.
https://blog.rust-embedded.org/newsletter-31/
autmotive (plastered with 1bn+$ companies) is actively exploring rust for functional safety, via AUTOSAR, and adacore and ferrous systems partner up for rust in ada-affine industries.
rust has this lovely habit of validating their compiler updates with their full collection of libraries, that's one step ahead of the validation contribution of SUSE, redhat, debian, canonical for common, linux packaged C/C++ libraries, because it happens on multiple OSs.
https://brson.github.io/2017/07/10/how-rust-is-tested
there is plenty of energy for formal verification of rust projects, too:
https://alastairreid.github.io/automatic-rust-verification-t...