Embedded C++ Kurs

Embedded C++ Basics Training

Training for embedded developers. Take advantage of C++17 and the MISRA C++ 2023 guidelines for ARM, STM32 etc. microprocessor applications.

This course is aimed at developers migrating from C or older C++ to modern C++ and need to learn the latest tools and best practices. Together with the Embedded C++ advanced course, this advanced course covers all topics that are important for programming embedded applications with C++.

Embedded programs are often characterized by special requirements. They often have a special program structure (setup, loop), no heap may be used to avoid memory fragmentation, they are interrupt driven, have to comply with requirements such as the MISRA guidelines, etc.

Traditionally, embedded programs are often written in C. With the advancement of compilers, most C++ features today no longer have any disadvantage over C in terms of code size and speed.

  • The new C++ standards (C++11C++14C++17) have introduced new features that result in faster and more compact code than the C alternatives.
  • One of the most important arguments in favor of C++ is that embedded programs are becoming more and more complex and larger. This complexity is often difficult to manage with C. Here, C++ offers enormous advantages that save development costs and contribute to the reliability of the applications
  • Most development environments for embedded programs (STM32CubeIDE, Espressif IDE, etc.) now support C++17.
  • The MISRA guidelines, which used to be primarily C-oriented, also point out the advantages of C++: „… now C++ is in the position once held by „C“;“
  • In addition, an outlook is given on the most important enhancements in C++20 and C++23, which will soon be available in the next gcc toolchains.

Course Objectives

This Embedded C++ basic training presents fundamental C++ features (e.g. types, statements, object-oriented programming). The focus is on the new language features of C++17 (including C++11 and C++14) and their use in embedded systems. These C++ topics are supplemented by

  • Numerous examples for common microcontrollers that demonstrates the usability of C++17 for common microcontroller boards (STM32ESP32Raspberry Pi etc.).
  • Best practices: The MISRA C++ 2023 Guidelines for safety-critical systems and the C++ Core Guidelines are presented together with the language elements. Adherence to these best practices is often recommended or required to obtain safe, maintainable and efficient C++ code.
  • An introduction to AI support for programming with Microsoft Copilot.

Target audience

This course is aimed at

  • experienced developers who want to write embedded applications using state-of-the-art C++17. It is also aimed at
  • decision-makers and technology managers, project leaders, etc., who want to evaluate how C++17 can optimize their teams‘ development processes.

It is often delivered as an in-house seminar so that companies can bring their teams up to date together.

Typical application fields:

  • Automotive and aerospace: developers who have to meet high safety and reliability requirements.
  • Industrial automation: programmers of complex control and monitoring systems.
  • IoT and smart devices: developers working on modern IoT devices where memory and performance optimizations are crucial.
  • Medical technology: engineers developing safety-critical and resource-efficient software for medical devices.

Prerequisites: good knowledge of C.

Contents

The contents can be adapted to the wishes of the participants.

1. Embedded Systems

  • Embedded application fields
  • Special requirements for embedded applications
  • Overview: C and C++ in comparison
  • ESP32 and STM32 boards

2. Fundamental Types and Statements

2.1 Integral and floating point types

  • Fixed-width integral types
  • Separators for number literals, binary literals
  • Implicit type deduction with auto
  • Type safe initializations with initializer lists
  • Bit operations

2.2 Control structures and functions

  • Conditional statements and loops
  • Initializations in for/if/switch
  • Functions
  • Interrupts and interrupt service routines (ISR)
  • Value and reference parameters
  • Using C and C++ libraries, namespaces
  • Default arguments
  • Function pointers, Interrupts and Interrupt Service Routines (ISR)
  • The „function type“ std::function

2.3 Constants

  • Runtime constants with const
  • Compile time constants with constexpr
  • constexpr functions
  • static_assert and unit tests at compile time

2.4 Overloaded functions and operators

  • Overloaded operators with global operator functions
  • Finding memory leaks with overloaded new and delete operators
  • User-defined literals

2.5 Enumeration types

  • Weakly typed enumeration types (C/C++03)
  • enum constants and conversions
  • Strongly typed enumeration types (C++11)
  • State machines and Task scheduling

2.6 Attributes

2.7 Modules (C++20)

  • Using the standard library as a module
  • Defining modules

3. The string classes string, wstring etc.

  • Member functions for string manipulation
  • Raw string literals
  • C++11 string conversion functions to_string, stoi etc.
  • C++17 string conversion functions: to_chars and from_chars
  • string_view – Strings for viewing
  • C++20: std::format

4. Arrays and containers

  • C-style arrays
  • C++ arrays: std::array
  • Dynamic Arrays with std::vector
  • Advantages of std::array and std::vector over C-style arrays

5. Pointers and Smart Pointers

  • Dynamic memory management
  • The nullptr literal
  • Pointer conversions
  • Smart pointers: shared_ptr, unique_ptr and weak_ptr

6. Object-oriented programming

6.1 Classes

  • Data Encapsulation with private and public
  • Constructors and Destructors
  • Classes without Pointers, RAII and the Rule of Zero
  • Initialization Lists as Parameters, for Arguments and Return Values

6.2 Class design: Safe and maintainable classes

  • The Default Constructor
  • Member Initializers
  • const and static Member Functions
  • Overloaded Operators
  • The Copy Constructor and the Assignment Operator
  • Userdefined literals and dimension analysis
  • Explicitly deleted and defaulted functions with =delete and =default
  • Converting and explicit constructors
  • Static class members
  • inline variables and static inline data members
  • Constant objects and member functions

6.3 Inheritance and Composition

  • Conversions between public derived classes
  • Hidden elements
  • Multiple inheritance
  • Virtual functions, late binding and polymorphism
  • override in C++11
  • Pure virtual functions and abstract base classes
  • Interfaces and multiple inheritance
  • Mocking interfaces and unittests

6.4 R-value references and move semantics

  • Move semantics in the C++ standard library
  • Move semantics for Rule of Zero classes
  • Move semantics for custom classes

About „Embedded C++ Basics Training“

Teaching style of the C++ seminar

Lecture with many examples. A balanced combination of theory and practice.

  • At the beginning of a new topic, an overview of applications, basic ideas and syntax is given.
  • The concepts and the syntax are illustrated by using carefully selected and proven examples. Often, best practices“ are presented.
  • The manuscript contains numerous practical exercises.
  • If desired, tasks from the work of the students can also be dealt with. This should be arranged before the start of the training.

Training Materials

Extensive and detailed training materials (approx. 200 pages) – Full text, no PowerPoint slides containing only keywords. Therefore, the course materials can also be used as a reference at work.

Place and time of this C++ training

This seminar is offered as an in-house seminar. It is recommended that it is held as a classroom training course. Online courses are also possible. Dates by arrangement.

Duration: 4-5 days (depending on prior knowledge)

Lecturer

Prof. Richard Kaiser has been conducting seminars for companies for many years, mainly on software development and the programming languages C#, C++ and C. He knows the requirements of practice and addresses them in detail, both in the basic concepts and in the details. His clients include renowned global corporations and small and medium-sized enterprises. He is the author of several books on C++, most recently „C++ mit Visual Studio 2019“. He was a member of the DIN standardization committee Information Technology NI-22 for many years.

Contact Prof. Richard Kaiser