Re: Coding embedded systems with C




James wrote:
> I heard C is better for programming embedded systems than C++? Is this
> true, if so why?
That kind of depends on what you mean by "embedded".

Are you short on ROM/RAM - such as having to fit in to a 64kB address
space? Then some C++ features will be unavailable. You can probably
forget about RTTI, exceptions and STL. Dynamic memory will be a very
tight squeeze to fit in. Much of C++ will work, though. I built a
simple RTOS in C++ a while back; on a Renesas H8, the kernel and two
empty tasks weighed in at 5kB of code. Turning on exceptions swelled
the code to 300kB, due to the mass of library functions that were
linked in.

However, a cellphone with memory sizes in the 16MB range is still an
embedded system - and there all the above features can be included.

Do you have special realtime requirements, such as having to meet a
hard deadline? Many people will tell you to be wary of exceptions in
such circumstances, since the timing of stack unwinding can be hard to
predict - at least in the parts of your code that needs to meet those
deadlines; in my experience, only a very small part of the code in a
realtime system is subject to the realtime constraints.

Anyway, the bottom line is that C++ can be considered a superset of C.
For any given project, examine your constraints. Use the extra C++
features that fit within those constraints, be they memory or timing
related. Skip the C++ features that don't fit.

.



Relevant Pages

  • Re: As a programmer of both languages...
    ... can do, and then add a few more features, such as classes, operator ... STL error messages almost don't frighten me anymore. ... writing a program for the PIC 16F684 microcontroller (which is less than ... still the king when it comes to embedded systems, ...
    (comp.lang.c)
  • Re: Common Myths for the Macintosh
    ... does rewrap around images in real time, but I suppose how 'real' depends on your computer's performance. ... of the many features suddenly got all that experienced flushed right down ... I suppose it might affect users who had more custom toolbars than you can fit into Office 2007. ... You won't admit anything is a competitor to iWeb unless it is *inferior* to iWeb ...
    (comp.sys.mac.advocacy)
  • Re: Whats right with FORTH and wrong with c.l.f.
    ... through FFI to C-written libraries. ... In the past, you've deprecated embedded systems programming, but the fact is there are far, far more microcontrollers in use in embedded systems than all the PCs and mainframes in the world. ... In embedded systems, you need easy and intimate access to hardware features and I/O under development, extremely low overhead I/O and interrupt handling, and low memory requirements. ...
    (comp.lang.forth)
  • Re: Whats right with FORTH and wrong with c.l.f.
    ... The rapid development is another frequent point of Forth proponents, ... through FFI to C-written libraries. ... In the world I work in, embedded systems, we need none of the ... access to hardware features and I/O under development, ...
    (comp.lang.forth)
  • Re: Best Method of Combining estimates
    ... >filters, each of which has a maximum output at a certain feature size ... >processing scheme. ... >I could run the filters with features of different lengths and get ... sounds as if a least squares fit using radial basis functions and a variable ...
    (sci.math.num-analysis)