Introduction to C++ Programming for Embedded and Application Developers
Course
Inhouse
Description
-
Type
Course
-
Methodology
Inhouse
-
Duration
5 Days
uses the GNU C++ compiler running under SUSE Linux. Projects are built using the traditional command-line-and-Makefile approach, and also using an Eclipse based C++ Integrated Development Environment. Applications are run on a PC running SUSE Linux, and also on an ARM9 board running ELinos Linux. We can tailor this course for other combinations of platform; for example: Suitable for: This course is designed for experienced C programmers with some experience of either embedded system or Win32 API or POSIX API programming.
Reviews
Course programme
This intensive, fast paced course enables experienced C programmers to begin writing embedded C++ software. It covers all the commonly used features of the C++ language and provides insights into the strengths and limitations of these features in the context of implementing embedded applications. Additionally, the course discusses the implemention of C++ class wrappers around C-based operating system APIs and TCP/IP socket APIs.
Practical work uses the GNU C++ compiler running under SUSE Linux. Projects are built using the traditional command-line-and-Makefile approach, and also using an Eclipse based C++ Integrated Development Environment. Applications are run on a PC running SUSE Linux, and also on an ARM9 board running ELinos Linux.
We can tailor this course for other combinations of platform; for example:
- Embedded IA32 target systems running Windows XP embedded or QNX Neutrino
- Microsoft Visual Studio or the Intel C++ Compiler 8.1 for development
- Embedded ARM9 target systems running a ThreadX kernel
- Development environments based on the Greenhills C++ compiler
Course Benefits
Migrating from C to C++ is challenging task if the true benefits of using C++ are to be realised. Unless careful thought is given to Analysis and Design, the resulting code may be little more than C code with C++ wrappers, with little or no gain in productivity through using an object-oriented language.
The real benefits of C++ come from:
- Expertise in object oriented analysis and design
- An understanding of object oriented programming patterns and idioms
- The ability to identify and use existing C++ frameworks, or to design and implement new frameworks from scratch
- Experience with the C++ STL (Standard Template Library) and the Boost C++ libraries
- Experience with C++ oriented user interface widget frameworks such as WxWindows or Qt Embedded
- Have a sound understanding of UML Notation to specify C++ applications and an ability to think and work with objects as the underlying abstraction
- Understand polymorphism and be able to identify situations where the use of polymorphism in an embedded system environment is appropriate
- Be able to make the best use of constructors and destructors, delete and new operators and understand key idioms and patterns such as reference counting, copy on modify, and the Singleton.
- Be able to write C++ code that can access embedded system hardware and can be used, for example, in writing device drivers
- Understand the advantages and disadvantages of wrapping C operating system API calls in C++ classes
- Understand C++ exception handling and the C++ RTTI (Run Time Type Identification) mechanism, and identify situations where their use is appropriate (or not)
- Be aware of object oriented patterns and their uses
- Be aware of framework oriented approaches and their uses
- Appreciate how to realise dynamic data structures and their associated algorithms in C++
- Understand the principles underlying templates and the STL, and decide where the use of templates and the STL is appropriate
- Be aware of C++ techniques for implementing small memory systems
- Be able to build applications that combine C++, C and assembler and that reuse existing C code and libraries
- Understand basic principles and strategies for wrapping operating system API functions in C++ clases - e.g. for multi-threading and inter-process communication
- Understand the design underlying the C++ IOSTREAM classes, where to use them in embedded applications, and where to use low level I/O in the C standard library instead.
Course Contents
Brief History of C++
- Early C++ (translation of C++ code to C code)
- C++ as an extension of C
- Non object-oriented C++ enhancements to basic C
- C++ as an evolving language and the development of the ANSI C++ standard
- Possible memory and performance costs of using C++ in embedded applications
- EC++ as a subset of C++ for use in the implementation of resource constrained embedded systems
- Base data types (numeric char, integer and floating point types)
- Pointers and arrays
- Function prototypes and function pointers
- structs , pointers to structs and dynamic data structures
- typedefs, enums and macros
- I/O in C
- Replacing C based I/O (printf, scanf etc) with C++ based I/O
- Function overloading
- Name mangling / decorating
- Mixing C and C++ code modules (use of extern C)
- Operators and operator overloading in C++
- Member variables and member functions (private, public, protected)
- Constructors and destructors
- Default constructors and default destructors
- Initialiser lists
- Derived classes
- Arrays of classes
- UML class diagram notation
- Copy constructors
- Deep vs. shallow copying
- Virtual functions and virtual classes (compile time vs. run time binding)
- Implementing dynamic data structures using classes (linked lists, binary trees, etc)
- Friend classes and friend functions
- Static member variables and static member functions
- Templates and the Standard Template Library
- The C++ iostream classes
- Overloading the insertion and extraction operators for use with user defined classes
- Reading and writing files
- Basics of object and data persistence
- The new and delete operators
- Overloading the new and delete operators
- Application specific memory management
- The concept and structure of exceptions and exception handling
- Throwing an exception
- The try block
- Catching an exception
- Re-throwing exceptions
- Catch-all handlers
- Exception specifications
- Exception handling implemention mechanisms
- Appropriateness of exception handling in embedded applications
- Alternatives to the C++ exception handling mechanism
- Data parameterised collections of classes and functions
- How C++ compilers handle templates
- The C++ Standard Template Library - a brief overview
- The Boost C++ libraries - a brief overview
- usefulness of namespaces in large projects and when re-using code
- Calling assembler from C
- Calling assembler from C++
- Benefits of C++
- Limitations of C++
- Patterns and idioms for accessing hardware from C++
- Patterns and idioms for bit manipulation in C++
- C++ embedded system programming idioms and patterns
- Polling techniques for synchronous I/O
- Interrupt driven techniques for I/O
- Implementing a low level interrupt handler in C++ for an operating-system-less application
- Implementing a simple timer-driven scheduler in C++
- Idioms and patterns for wrapping C operating system APIs in C++ (Inter Process Communication and Task Management)
- Thread, semaphore, pipe, task, timer, monitor and shared memory classes
- Implementing a simple timer-driven scheduler in C++
- Device driver class hierarchies
- Accessing Special Function Registers (SFRs)
- #pragma s
- Compiler-specific non-ANSI C++ extensions
Introduction to C++ Programming for Embedded and Application Developers
