Alex said:
Are there any restrictions/problems for use of C++ STL in development
in embedded systems?
[snip]
In general, you can't give a simple answer to such questions.
The specifics of how your particular embedded system works
are going to, in the extreme cases for various features, be the
choke point.
Consider a case where, for hardware reasons, you needed to
limit the amount of RAM on your system to the absolute
smallest possible amount. Anything that produced an extra
temp variable, an extra chunk of something shoved on the
stack, etc. etc., would be hard to accomodate. In such a case,
it might be easier to get your job done in some other language
than C++. Possibly assembler, for example. Though as time
goes by, the amount of RAM available on most hardware is
increasing. I recall a project from many years ago where
an industrial monitor (radiation hand and foot checker) had
a very small amount of RAM, like 128 bytes or some silly
small number. Trying to fit a C++ prog into such hardware
would have been tiresome. RAM is much cheaper these days.
The latest version of this device has a huge whack of RAM.
Other considerations: Suppose the system cannot require
human intervention, or human intervention is expensive in
some way. In such a case, a "bullet proof" implementation
that won't crash, won't leak resources, etc., is going to be
a big concern. A good implementation of the STL will look
pretty good in such cases, as compared to a roll-your-own
set of containers. So will reading the series of books
"Effective C++", "More Effective C++", and "Effective STL"
(though I may have munged the titles).
There are many other possible concerns. For example:
You need a compiler that outputs optimized code for
your hardware. This is crucial above all else. If the code
won't run on your hardware, there's no point worrying
about what library to use. So, if your compiler has limits
(not unusual in the case of hardware specific compilers,
though getting better) you should start with your list of
possible compilers, and figure out what is possible from
that. If the only compiler available is an older non-compliant
one, you may have trouble getting a good STL implementation
to work on it. I recall another project from many years ago
where the only compiler that would output code for the
hardware was a C compiler. And an old (1988 or so) C compiler
at that. Tiresome.
What other libraries are required for the project? If it's
a specific chunk of hardware, chances are there is an
API kit provided by the manufacturer. The advantages of
using such a kit may outweigh the advantages of using
the STL, supposing you can't use both. Though, again,
as time goes by most hardware makers are supporting
the STL, and more modern implementations of it.
There are many other possible considerations. For
example, if you explore these issues, the client might
be convinced that the extra RAM might be worth it in
order to be able to shorten the development time. Or
to be able to do the development in C++ rather than
assembler, and so be able to provide lots of new
sexy features in the same development time.
Socks