Re: C++ for Embedded Systems.
peter koch larsen wrote:
[concerning EC++...]
I believe I would recommend regular C++ in all but the
tightest environments.
I think most people would. I think that the alterative,
however, is more often C, and not regular C++. Whatever its
flaws, I suspect that EC++ has permitted a lot of applications
to use classes, etc., which otherwise would have been written in
C.
[...]
In fact I observed on average they did better than some of
the handcrafted implementations in our C systems.
Of course... if you only need one container you have the time
to spend more time optimising.
I think it's a question of the skill and effort involved. I've
used at least four different STL implementations. At least two
(the one with g++ and the Dimkumware version which comes with
VC++) are far better than anything I could possibly come up with
myself (and I would rate my C++ skills above average). The
authors of both are either more skilled than I am, or invested
more time than I could (or most likely both).
What I'm seeking guidance on is the usage of C++ / STL that
"optimizes for ram/rom size" rather than speed. Sort of like
-Os for STL usage guidelines.
The other common requirement in embedded systems is
determinancy. We need to know, even more than in desktop /
server apps, at design time the worst case behaviour. (Which
to me is an argument for using STL in embedded systems.)
However, a standard C++ gotcha is the time to process an
exception. A style guideline for embedded programmers should
probably highlight that in the appropriate context.
These are the sort of C++ vs Embedded gotchas and guidelines
I'm seeking.
This requires detailed study/analysis of the given compiler.
It depends on the level of detail you want. How to implement
exception handling is generally known, and it has a large cost
in code space. It's also generally accepted that raising an
exception and catching it are fairly expensive operations; if
you're writing a critical hard real-time function that has an
upper limit of 100us execution time, its something you don't
want to do.
--
James Kanze GABI Software
Conseils en informatique orient?e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S?mard, 78210 St.-Cyr-l'?cole, France, +33 (0)1 30 23 00 34
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]