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
- Objectives of AUTOSAR C++14
- 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.
- Some elementary member functions of the string class
- Raw string literals (raw strings)
- C++11 String Conversion functions: to_string, stoi etc.
- C++17 Conversion functions: to_chars and from_chars
- 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
- AUTOSAR 6.18.5: Dynamic Memory Management
- The nullptr Literal
- Pointer Conversions
- C++11 Smart Pointer: shared_ptr, unique_ptr und weak_ptr
- Similarities of unique_ptr and shared_ptr
- unique_ptr
- shared_ptr
- Deleter and smart pointer for Arrays
6. Object-Oriented Programming
Classes, Data Members and Member Functions
- Data Encapsulation: Access rights private and public
- Constructors and destructors
- Initializer lists for arguments and return values
- Initializer Lists as Parameters
- The Default Constructor
- Members Initializers
- Overloaded operators with member functions
- The copy constructor and the assignment operator
- Explicitly Deleted and Defaulted Functions with =delete and =default
- Converting and explicit constructors
- Static class members
- inline variables, especially static inline data elements
- Constant objects and member functions
Inheritance and Composition
- Conversions between public derived classes
- Multiple inheritance and virtual base classes
- Virtual functions, late binding and polymorphism
- Virtual functions with override in C++11
- Pure virtual functions and abstract base classes
- OO-Design: Virtual Functions and Abstract Base Classes
- Interfaces and multiple inheritance
R-value references and Move semantics
7. namespaces
8. Exception Handling
- try / catch and stack unwinding
- RAII
- noexcept
9. Templates
Generic Functions: Function Templates
- Declaring Function Templates with Type Parameters
- Specializations of function templates
- Function Templates with Non-Type Parameters
- Explicitly specialized and overloaded Templates
Generic Classes: Class Templates
- The Declaration of Class Templates with Type Parameters
- Specializations of Class Templates
- Class Templates with Non-Type Parameters
10. Functors, function objects and lambda expressions
The call operator ()
Lambda expressions
STL algorithms and lambda expressions
- Linear search
- Counting
- Search for subsequences
- Use all_of, any_of, none_of to check all elements in a range
- Transform and replace elements
- Sorting
- Binary search in sorted Containers
- Parallel algorithms of the STL, e.g. std::sort
- Parallel for with for_each.
- 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
- Create container with monotonic_buffer_resource on the stack or globally
- Benchmarks: pmr containers are often 3-5 times faster
- 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