Crafting Embedded Software in C++

C++ Embedded

By far, C is the dominant language for embedded programming. Unfortunately, too many embedded developers stay with C because they believe that C++ is too complex, too inefficient, too dangerous, or too whatever for embedded programming. In fact, C++ is in many ways demonstrably better suited than C for this task.

This seminar explains how to use C++ to write embedded programs. Specifically, it shows how to employ C++ classes and templates to write readable, yet efficient, abstractions that represent and manipulate hardware devices running in a freestanding (bare metal) environment. Although the seminar focuses primarily on techniques that employ only standard features of C++, of necessity it covers a few aspects that require non-standard features.

Using real programming examples running on real hardware, this course explains how to use C++ features such as classes, overloading and user-defined type conversions to hide messy hardware details behind cleaner interfaces. It shows how to use templates and inheritance to capture commonality among devices and promote code reuse without sacrificing performance. It shows practical application of C++ features to make your embedded code more ROMable, safer, faster, smaller, and more maintainable. It emphasizes programming styles and idioms that turn potential run-time errors into compile-time errors, and turn run-time computations into compile-time computations.


Participants should have basic knowledge of the C++ language and standard library.

This course includes programming exercises. The exercises run on a simulator provided by the instructor. Each exercise compiles and links with the simulator in C++ and executes as a command-line application. Please bring a computer with a recent C++ development environment that can build command-line applications.


09:00 - 17:00


  • Using const and volatile appropriately
  • Memory-mapped object placement and initialization
  • Hardware abstraction techniques
  • Static vs. dynamic initialization
  • POD and standard-layout types
  • Alignment and padding concerns
  • Write-only semantics
  • Const semantics vs. read-only semantics
  • Co-located and interwined devices
  • Interrupt numbers, vectors and tables
  • Interrupt handling frameworks
  • Language linkage
  • Race conditions, critical sections, and atomic types