Embedded-Friendly C++: Features That Make a Difference
C++ is used in many different fields. One that sticks out is the embedded domain, you're often working with tight constraints. Writing software is challenging and fun at the same time.
What has C++ done to support this field? What new options do you have to avoid undefined behavior, write more efficient and robust code?
In this talk, I will present various library elements as well as language improvements that make writing embedded software better.
We'll look at real-world tasks like turning raw byte blobs into usable data structures, aka type punning, of course, without triggering undefined behavior. C++26 supports you in a new way with std::start_life_time_as. I'll explore that new library function with you, including solutions for pre C++26.
Transferring data via a network comes with its own challenges. You have to care about the byte order. Oh, and how can you make sure that there are no padding bytes included? Well, I have an answer for you.
By the end of this talk, you know the most important improvements in C++ for embedded or similar environments.
What this presentation is about and why it matters
How do you use newer C++ features to make embedded code safer, more expressive, and still practical on real hardware? Andreas Fertig walks through that tension with a small remote-controlled light bulb example, using it to connect language features from C++17 through C++23 to everyday embedded concerns like object layout, compile-time work, parsing, and byte order. The format is a hands-on walkthrough, not a theory lecture, and it stays grounded in code you can mentally map to your own projects. It is especially relevant if you work close to hardware, protocol parsing, or low-level data handling.
Who will benefit the most from this presentation
- Embedded C++ developers who want to understand which newer language features are worth adopting in constrained codebases.
- Firmware engineers who serialize, parse, or transport structured data and need to think about layout, padding, and byte order.
- Tech leads or architects evaluating whether C++20 and C++23 features fit an embedded project without adding unnecessary complexity.
- Developers maintaining older code who suspect parts of their low-level code rely on undefined behavior.
What you need to know
You will get more from the talk if you are comfortable reading modern C++ and basic embedded-style data handling.
- Familiarity with
struct,enum class, and constructors. - Basic awareness of compile-time versus runtime execution.
- Some exposure to serialization, network messages, or endianness concerns.
- A working sense of why undefined behavior matters in C++.
Glossary (terms used in this talk)
- if consteval: A compile-time branch that selects code only when evaluation happens during constant evaluation. It is useful for keeping runtime-only code out of constexpr contexts while still allowing a function to be usable at compile time.
- std::is_constant_evaluated(): A library utility that reports whether the current evaluation is happening at compile time. It can be used to conditionally select different behavior for constant-evaluated and runtime execution paths.
- STD span: A non-owning view over a contiguous sequence of elements. It lets one function accept arrays and containers without copying data.
- MAC address: A hardware identifier for network interfaces, usually 6 bytes long and displayed as six hexadecimal blocks separated by colons or dashes. Used to uniquely identify network devices on a local network.
- FP16 (half-precision floating point): A 16-bit floating point format (half precision) used when 32-bit float precision is unnecessary, offering a smaller storage footprint at the cost of range and precision.
- std::expected: A C++ type that represents either a successful value or an error; it carries an explicit error value when the operation fails and helps make error cases explicit compared to std::optional.
- std::unexpected: A helper type used to construct an error state for std::expected, representing an unexpected error value to initialize the expected object in its error state.
- std::to_array: A C++20 utility that converts a string literal or other aggregate into a std::array of elements, producing an array of characters for string literals rather than a pointer.
Final thoughts
Practical and example-driven, this talk gives a clear view into how modern C++ can reduce risk in embedded code without turning it into a language showcase. The value here is a sharper mental model for when compile-time techniques, safer library facilities, and newer syntax help, and when older habits quietly cross into undefined behavior. It will especially help embedded developers who read low-level code every day. The session leaves you with a more careful way of thinking about the bytes underneath the objects.
This overview is AI-generated from the session transcript. Spot an issue? Let us know.
Thank you, really a lot of C++ goodies.
About slide 14, std::start_lifetime_as, if I interpret correctly, the code skips one byte in the data array (data[0] is the Protocol::Update, and the subspan first argument is 2). This preserves the correct alignment for LightBulbControl that, otherwise, being received from an I/O, could be at any address. Does the std::start_lifetime_as automatically fix the alignment issues?
Thanks Andreas! A couple of comments if I may:
1) You REALLY need a better microphone, you have some slight echo+clipping that makes it really hard to understand you (both this presentation and recent panel discussion). I had this problem and switched to Snowball Ice (which I should have used today).
2) This presentation never showed slide 4, slide 3 was still showing while you discussed slide 4.
Minor stuff though, Thanks again!
Best Regards, Dave
Andreas thank you for an insightful presentation I really enjoyed it, good collection of nifty features introduced in recent standards very fitting to embedded development.
With contexpr and consteval expressions providing the opportunity the best chance to do a lot of the heavy lifting, do you know how the debug experience is like when stepping through them in a session? Are they literally "optimised out" by design, as the compiler may reduce them to a minimum?
Just a quick note mainly for the rest of attendees, slide 4 didn't seem during the talk but the recorded explanation can be perfectly followed by downloading the complete deck attached.








Would be nice to have a summary slide (ideally at the beginning) showing the features that are discussed. Very useful content, by the way. Thanks, and as already pointed out, the audio quality is a problem. Might be as simple as reducing the microphone gain to eliminate the clipping that make it hard to understand.