Re: C++ for Embedded Systems.
Jiang wrote:
Mike wrote:
John Carter wrote:
Since both std::string and STL containers use general
purpose dynamic memory allocation which is
non-deterministic, I suspect this might be the reason
they're left out.
If this is true, why most of the embedded compilers provide
new/delete operators?
Because you don't have to be deterministic everywhere, all of
the time.
For the most part, I'd be sceptical of using the STL in a
situation where memory was critical. The STL was designed more
with speed in mind, and often trades memory for speed. But
there, too, there are exceptions: and std::vector created with
the final size (or on which reserve has been called with the
final size) won't do any more allocations, and probably doesn't
use any more memory than the alternatives.
Although, the streams library generally uses dynamic memory
allocation, so I wonder how they could provide streams and
not the std::string and STL containers?
I believe the possible reason why these libraries are omitted
is, well, those compilers do not support exception and locale,
or even template. Unfortunately (or fortunately if you are
compiler writer), this is EC++ standard conformed behavior.
Most of the EC++ standard conforming compilers get there by
removing existing functionality, so this doesn't help them. I
suspect that generally speaking, EC++ doesn't support templates
more for historical reasons than anything else; back when EC++
was being specified, templates were an experimental oddity, that
didn't always work very well. Exceptions, on the other hand,
have very significant code size costs (or stack and runtime
costs---it's a pick), and aren't really applicable to most
embedded applications.
But it is also true that some vendors did much more, instead
of just holding a EC++ standard in hand. The cl6x (by TI)
supports template, namespace and even RTTI. I really
appreciate this kind of challenge.
I think that this is more or less what EC++ aims for. Not an
exclusive, all inclusive standard, but a sort of minimum, to
which an implementor is free to add features from standard C++,
according to the needs of his clientel. I would be very
disappointed today if an EC++ compiler didn't support templates.
I would also be somewhat bothered if I couldn't turn off its
support for exceptions and RTTI, because these do have
significant code size costs.
--
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! ]