R
Randy Howard
We made very good experience with C++ on embedded systems even for time
critical tasks.
For our system we restricted the C++ features that are allowed. Those
are:
- no dynamic memory allocation (no new, delete, malloc, free etc.)
- no exceptions
- no run time type information
- no virtual functions
- no templates
So why use it?
The resulting software is very modular and and code is easy to read. We
almost never had any of those typical C memory access errors...
Strange, I use C instead of C++ and don't have "typical C memory access
errors". What are you referring to, specifically?
The great benefits of C++ over C in this projects are:
- excessive usage of references instead of pointers makes the code very
robust
How does it make it more robust? Do you really mean that it helps
programmers who don't know C and pointers very well?
- excessive usage of const classifiers avoids mis-usage of objects
Is it excessive, or not?
- class access rights + lightweight inline methods (set, get) assure
protection of internal module variables. Old projects were full of
those evil extern declarations...
Ah, so you don't have C-literate programmers. You might want to
investigate how ADT's are properly implemented in C.
One of the disadvantage of C++ is a slightly greater memory footprint
because C++ environment initialization is more sophisticated...
That's ok, embedded platforms always have plenty of memory.
I really like the beauty of our lightwight wrappers for hardware
interfaces. Almost no runtime-overhead, intuitive usage, and very
robust against abuse at the same time.
Who "abuses" embedded software, other than the implementor(s)?
Much better than anything that you can achieve in C.
Not true. Perhaps you meant to write "I" instead of "you".