Embedded C++ and AUTOSAR C++ 14

Inhalte Verbergen

Embedded C++, MISRA and AUTOSAR C++14

In March 2017, AUTOSAR presented guidelines for the use of the
C++14 language in critical and safety-related systems
. These rules are essentially an extension of the MISRA C++ rules of 2008. In January 2019 Misra announced that the Misra C++ and Autosar rules will be combined to a common set of rules based on C++17.

This seminar is a thorough presentation of the C++ features allowed in AUTOSAR C++14 (especially C++11, C++14 and C++17). These rules hold for many embedded applications that are written in C++.

1. MISRA and AUTOSAR C++14

  1. Objectives of AUTOSAR C++14
  2. C++ Features Allowed in AUTOSAR C++14

2. Fundamental Types and Statements – C++ vs C

2.1 Integral Types

  • Fixed width integer types
  • Separator for number literals, binary literals
  • Type Inference: Implicit Type Assignments With auto
  • Implicit Conversions and Safe Conversions with Initializer Lists
  • std::byte

2.2 Control Structures and Functions

  • Conditional, Iterative and Compound Statements.
  • Init Statement for if/switch
  • Functions
  • Conditional compilation with if constexpr
  • Value- and Reference Parameters
  • Using Libraries and Namespaces
  • Default Arguments

2.3 Floating-Point Types

2.4 Constants

  • Runtime Constants With const
  • Compiletime Constants With constexpr
  • constexpr Functions
  • static_assert and unit tests at compile time

2.5 Synonyms for Types with typedef and using

2.6 Overloaded functions

  • Overloaded operators with global operator functions
  • Userdefined Literals

2.7 Order of Evaluation in Expressions since C++17

2.8 Enumeration Types

  • Weakly typed enumeration types (C/C++03)
  • enum Constants and Conversions
  • Strongly Typed Enumeration Types (C++11)

2.9 Attributes

2.10 The Visual Studio C++ Core Guidelines Checker

2.11 Modules (C++20)

  • Using the standard library as a module
  • Defining modules

3. String classes: string, wstring etc.

  1. Some elementary member functions of the string class
  2. Raw string literals (raw strings)
  3. C++11 String Conversion functions: to_string, stoi etc.
  4. C++17 Conversion functions: to_chars and from_chars
  5. string_view -Strings to view

4. Arrays and containers

  • One-dimensional arrays
  • C style Arrays
  • C++ Arrays: std::array
  • Dynamic arrays of type std::vector
  • The initialization of arrays during their definition
  • Advantages of std::array and std::vector over C style arrays

5. Pointers and Smart Pointers

  1. AUTOSAR 6.18.5: Dynamic Memory Management
  2. The nullptr Literal
  3. Pointer Conversions
  4. C++11 Smart Pointer: shared_ptr, unique_ptr und weak_ptr
  5. Similarities of unique_ptr and shared_ptr
  6. unique_ptr
  7. shared_ptr
  8. Deleter and smart pointer for Arrays

6. Object-Oriented Programming

Classes, Data Members and Member Functions

  1. Data Encapsulation: Access rights private and public
  2. Constructors and destructors
  3. Initializer lists for arguments and return values
  4. Initializer Lists as Parameters
  5. The Default Constructor
  6. Members Initializers
  7. Overloaded operators with member functions
  8. The copy constructor and the assignment operator
  9. Explicitly Deleted and Defaulted Functions with  =delete and =default
  10. Converting and explicit constructors
  11. Static class members
  12. inline variables, especially static inline data elements
  13. Constant objects and member functions

Inheritance and Composition

  1. Conversions between public derived classes
  2. Multiple inheritance and virtual base classes
  3. Virtual functions, late binding and polymorphism
  4. Virtual functions with override in C++11
  5. Pure virtual functions and abstract base classes
  6. OO-Design: Virtual Functions and Abstract Base Classes
  7. Interfaces and multiple inheritance

R-value references and Move semantics

7. namespaces

8. Exception Handling

  1. try / catch and stack unwinding
  2. RAII
  3. noexcept

9. Templates

Generic Functions: Function Templates

  1. Declaring Function Templates with Type Parameters
  2. Specializations of function templates
  3. Function Templates with Non-Type Parameters
  4. Explicitly specialized and overloaded Templates

Generic Classes: Class Templates

  1. The Declaration of Class Templates with Type Parameters
  2. Specializations of Class Templates
  3. Class Templates with Non-Type Parameters

10. Functors, function objects and lambda expressions

The call operator ()

Lambda expressions

STL algorithms and lambda expressions

  1. Linear search
  2. Counting
  3. Search for subsequences
  4. Use all_of, any_of, none_of to check all elements in a range
  5. Transform and replace elements
  6. Sorting
  7. Binary search in sorted Containers
  8. Parallel algorithms of the STL, e.g. std::sort
  9. Parallel for with for_each.
  10. std::reduce and std::transform_reduce 

11. Polymorphic Memory Ressources (pmr), STL Containers and AUTOSAR C++

The standard allocators of STL containers

Tracking new and delete

Allocators and polymorphic memory resources

  1. Create container with monotonic_buffer_resource on the stack or globally
  2. Benchmarks: pmr containers are often 3-5 times faster
  3. Allocators in C++17

About „Embedded C++ and AUTOSAR C++ 14“

Target audience

Software developers who want to write professional programs for embedded applications with C++.

Background knowledge: Good C and C++ knowledge.

Teaching style

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.

Time and place, online or face to face

This seminar is offered as an inhouse seminar (at your site). The implementation as a face-to-face seminar is preferred, but is also possible as an online seminar. Dates by arrangement.

Duration: 5 days

Contact Prof. Richard Kaiser