This week I spent three days with Dan Saks and twelve others in Cleveland taking in Dan's "Embedded Programming with C++" which presented techniques for developing robust and efficient embedded applications in C++. This was Dan's first ever public class on the subject.
A lot of time of the first day was spent going over the language of the C and C++ standards so that everyone in class was at the same level of understanding, with the end goal of being able to read the standards and be able to comprehend them. A lot of time was spent on the difference between declarations and definitions, scope, and linkage. Perhaps a bit to much time was spent in this area, as toward the end of the class on the last day things were starting to seem rushed.
On day two we covered how not to get the standard C++ library sucked into to our build, as this is usually the source of the perception of C++ code being bloated compared to plain C code. Also covered was the proper ways to use const and our friend and nemesis volatile; see "Nine ways to break your systems code using volatile". Spent the majority of the day building up an I/O class a step at a time. While Dan explained how and why each step was an improvement over the previous version. Some time was spent comparing the memory sizes of equivalent C and C++ programs. In the end the C++ program was only four bytes bigger than the C program. In some examples that where run on the ARM architecture the C++ versions were actually smaller than the C versions.
Day three Templates, and some discussion of Template Specialization, were covered. For example on the AVR XMega there is eight USARTs. Templates give a simple interface to cover the USARTS. Also covered was how to write read-only and write-only classes that would abort at compile time if they were used in the wrong direction, such as reading from a write-only register. One of the last thing covered was how to write a library that would cause the build to failed if anything used 'new' (perhaps it was hidden in a third party library), as MISRA frowns on dynamic memory usage.
Overall if you ever hear of Dan giving a class in your area, make the time to take it.
No comments:
Post a Comment