6 ms·
Learn Effective C++ for Embedded Code
- immmmmm 4y agoThe Embedded Template Library seems relevant here: https://www.etlcpp.com/ https://www.etlcpp.com/
- bigredhdl 4y agoI'm a big fan of quantum leaps (www.state-machine.com) for c++ embedded. I am not affiliated with them in any way, just had a great experience with it.
- buescher 4y agoI have not used their libraries or tools, but Miro Samek's book is great. There's a C implementation covered in it also. It's a bit of a master class in embedded C programming with careful use of structs and function pointers for "object orientation".
- JohnTordur 4y agoHe also has an awesome YouTube channel which goes from pretty much zero and explains many embedded topics. Oh, and the book is free: https://www.state-machine.com/psicc2 https://www.state-machine.com/psicc2
- bfrog 4y agoI’m always under the impression that C++ has some issues when it comes to embedded and that only a subset can be used, that the stdlib and stl cannot be used. I still don’t really understand how c++ behaves with exception handling thrown in the mix, where all sort of weird gotchas seemingly come into play. 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?
- oytis 4y ago> I still don’t really understand how c++ behaves with exception handling thrown in the mix 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.
- bfrog 4y agoSeeing c, seeing the assembly and memory layout, debugging is pretty easy. More than once I’ve ran into C compiler bugs. I can imagine running into the same issue with C++ being pretty troublesome?
- oytis 4y agoOh. Frankly I've probably never seen a compiler bug in my life. I have to look at the assembly sometimes though when debugging faults of various kinds, and I don't find matching C++ to assembly significantly more complicated than C. There is just a bit of additional knowledge maybe on how vtables work and that's it. Exceptions are probably a pain too, but embedded code doesn't allow them as a rule.
- jcelerier 4y ago
- nynx 4y agoRust on embedded seems a hell of a lot more viable for large, complicated projects. You can basically use the entire standard library (sans io and alloc, obviously).
- oytis 4y agoEntire core library you mean? std is normally not supported on embedded targets AFAIK.
- bluGill 4y agoEmbedded is very conservative. While Rust is looking promising, it will be a while before it is trusted like the embedded subset of C++ is (that is no exceptions and other parts that embedded often turns off). That time may or not find faults with Rust (including some faults that are today considered a good thing). The movers and shakers in the embedded C++ world are looking at Rust though.
- luvs2code 4y agoGonna need a citation on that one. I work in the embedded world for a billion+ dollar company and there is zero interest or adoption in Rust.
- bluGill 4y agoIt has got enough attention that SG14 (the C++ embedded working group) is asking questions and trying to figure out what to do about it. Most of the committee seems aware of it, some have looked into it more than others. That doesn't mean everyone is looking at it. Like I said, embedded is conservative, so it will be a while before everyone looks.
- froh 4y agohere we go: https://blog.rust-embedded.org/newsletter-31/ 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 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-tools-2021/ https://alastairreid.github.io/automatic-rust-verification-t...
- ilayn 4y agoNo.