Crafting Embedded Software in C++ [2017 Class Archive]

“Crafting Embedded Software in C++” is a two-day training course with programming exercises taught by Dan Saks of Saks & Associates. It is offered at the Sheraton Bellevue Hotel from 9AM to 5PM on Saturday and Sunday, September 30th and October 1st, 2017 (immediately after the conference). Lunch is included.

Course Description

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 embedded programming.

This seminar explains how to use Modern C++ to write embedded programs. Specifically, it shows how to employ C++ 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 single-board computers, 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 Modern C++ features such as constexpr, static_assert, and type_traits 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 C++11 or C++14 development environment that can build command-line applications.

Course Topics

  • 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

Course Instructor

Dan SaksDan Saks is the president of Saks & Associates, which offers training and consulting in C and C++ and their use in developing embedded systems. He has been a columnist for The C/C++ Users Journal, The C++ Report, Embedded Systems Design, and several other publications. Dan served as the first secretary of the C++ Standards Committee and contributed to the CERT Secure Coding Standards for C and C++.