C vs C++ in Embedded Systems? - Page 4

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Re: C vs C++ in Embedded Systems?

Quoted text here. Click to load it

I apologize. I shouldn't have implied that you were trolling.


Re: C vs C++ in Embedded Systems?

Quoted text here. Click to load it

HEY! What about *my* favorites; 4-bit CPUs with 64 nybbles of RAM?

Not a lot of call for C++ on those... :)

Re: C vs C++ in Embedded Systems?
Quoted text here. Click to load it

I disagree. I consider OO at least as much a design technique as a language

I agreed with the rest of your post, though ;).


Re: C vs C++ in Embedded Systems?
Quoted text here. Click to load it

This is most obviously a taste issue. 8-bit processors can be whipped to do
amazing things, but considering the simplest example, like a PWM generator,
then OO design technique feels a bit like overshoot. To each by their taste,
however :)

Quoted text here. Click to load it

At least we agree on something :)

-Antti Keskinen

Re: C vs C++ in Embedded Systems?

Quoted text here. Click to load it
OO techniquies will improve 8 bit controllers when they are designed to use
So far NO 8 bitters think about OO but consider.

      PERIPHERAL(BYTE config);
    void     enable_interrupt(void)     { mode |=      0x02; }
    void     disable_interrupt(void)    { mode |=      0x02; }
    void     start(void)                        { mode |=      0x01; }
    void     stop(void)                         { mode &= ~0x01; }
    bool     ready(void)                       { return ((status & 0x04) !=
    BYTE  config;
    BYTE  mode,
    BYTE  status;

class TIMER : public PERIPHERAL
    BYTE    counter;
    BYTE    reload_high
    BYTE    reload_low;

class    SPI : public PERIPHERAL
     BYTE    data;

By using the inheritance mechanism for the definition of the peripherals
the code size for an 8 bit controller will be reduced.
The code to enable interrupt for the SPI will be the same as the code for
enabling interrupt for the timer.
They can thus share the same configuration routine.

If you have 4 UARTs in the device, and the interrupt
for a certain UART automatically maps in the UART register
to a static location, you will save a LOT of code space.-

OO is the way to go for lower cost, (Embedded) C++ is the only alternative,
practically available and has to be used with extreme care.

Best Regards,
Ulf Samuelsson
We've slightly trimmed the long signature. Click to see the full one.
Re: C vs C++ in Embedded Systems?
I have personally used C++ for an embedded system which is used in a
consumer electronics appliance.We used C when it requires Hardware
interaction and C++ in the application level to generate UI,Menus and
stuff like that.Really We enjoyed the reusability feature of C++ and
did not see any performance problems though.I would prefer a mix of
both ,though depending on the system.If you really want reusable code
and want to maintain good maitainability in the code in the
application perspective(though not on h/w interaction),I feel C++ will
be your best bet.I raised the same query a few days back and was
informed,instead of blaming the language,better learn the language to
use efficiently.I till now have the same opinion.Any language can be
used to best way it can work,if you know how to use it efficiently.If
you feel it does not fit your application,it does not mean,the total
language is useless!I believe totally rejecting C++ for embedded is
not a fair judgement.

P.S:I have no experience with other OO languages,so I will restrict my
opinion only to C++.


Site Timeline