Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > C or C++ for embedded system plug-in?

Reply
Thread Tools

C or C++ for embedded system plug-in?

 
 
Randy Howard
Guest
Posts: n/a
 
      01-10-2007
On Thu, 4 Jan 2007 07:56:11 -0600, Henryk wrote
(in article <(E-Mail Removed). com>):

> We made very good experience with C++ on embedded systems even for time
> critical tasks.
>
> For our system we restricted the C++ features that are allowed. Those
> are:
> - no dynamic memory allocation (no new, delete, malloc, free etc.)
> - no exceptions
> - no run time type information
> - no virtual functions
> - no templates


So why use it?

> The resulting software is very modular and and code is easy to read. We
> almost never had any of those typical C memory access errors...


Strange, I use C instead of C++ and don't have "typical C memory access
errors". What are you referring to, specifically?

> The great benefits of C++ over C in this projects are:
> - excessive usage of references instead of pointers makes the code very
> robust


How does it make it more robust? Do you really mean that it helps
programmers who don't know C and pointers very well?

> - excessive usage of const classifiers avoids mis-usage of objects


Is it excessive, or not?

> - class access rights + lightweight inline methods (set, get) assure
> protection of internal module variables. Old projects were full of
> those evil extern declarations...


Ah, so you don't have C-literate programmers. You might want to
investigate how ADT's are properly implemented in C.

> One of the disadvantage of C++ is a slightly greater memory footprint
> because C++ environment initialization is more sophisticated...


That's ok, embedded platforms always have plenty of memory.

> I really like the beauty of our lightwight wrappers for hardware
> interfaces. Almost no runtime-overhead, intuitive usage, and very
> robust against abuse at the same time.


Who "abuses" embedded software, other than the implementor(s)?

> Much better than anything that you can achieve in C.


Not true. Perhaps you meant to write "I" instead of "you".

--
Randy Howard (2reply remove FOOBAR)
"The power of accurate observation is called cynicism by those
who have not got it." - George Bernard Shaw





 
Reply With Quote
 
 
 
 
Lionel B
Guest
Posts: n/a
 
      01-10-2007
On Wed, 10 Jan 2007 00:24:48 +0000, Randy Howard wrote:

> On Thu, 4 Jan 2007 07:56:11 -0600, Henryk wrote
> (in article <(E-Mail Removed). com>):
>
>> We made very good experience with C++ on embedded systems even for time
>> critical tasks.
>>
>> For our system we restricted the C++ features that are allowed. Those
>> are:
>> - no dynamic memory allocation (no new, delete, malloc, free etc.)
>> - no exceptions
>> - no run time type information
>> - no virtual functions
>> - no templates

>
> So why use it?
>
>> The resulting software is very modular and and code is easy to read. We
>> almost never had any of those typical C memory access errors...

>
> Strange, I use C instead of C++ and don't have "typical C memory access
> errors". What are you referring to, specifically?


I suspect he meant such things as attempting to dereference a pointer to
NULL or to the "wrong" area of memory, forgetting to deallocate memory
(memory leakage), reading/writing past the end of an array or memory
buffer, ...

C++ does have mechanisms lacking in C to assist in avoiding these errors,
such as the ability to do memory allocation/deallocation in
constructors/destructors, overloading of operators to implement array
bounds checking and ...

>> The great benefits of C++ over C in this projects are:
>> - excessive usage of references instead of pointers makes the code very
>> robust

>
> How does it make it more robust? Do you really mean that it helps
> programmers who don't know C and pointers very well?


It is possible, but you have to be almost wilfully perverse, to initialise
a reference with a NULL/invalid address.

>> - excessive usage of const classifiers avoids mis-usage of objects

>
> Is it excessive, or not?


Perhaps "consistent usage wherever appropriate" might have been a better
phrase

>> - class access rights + lightweight inline methods (set, get) assure
>> protection of internal module variables. Old projects were full of
>> those evil extern declarations...

>
> Ah, so you don't have C-literate programmers. You might want to
> investigate how ADT's are properly implemented in C.


Perhaps "properly implementable" might be more accurate. I would suggest
that C++ makes encapsulation and object access control easier than it is
in C.

>> One of the disadvantage of C++ is a slightly greater memory footprint
>> because C++ environment initialization is more sophisticated...

>
> That's ok, embedded platforms always have plenty of memory.
>
>> I really like the beauty of our lightwight wrappers for hardware
>> interfaces. Almost no runtime-overhead, intuitive usage, and very
>> robust against abuse at the same time.

>
> Who "abuses" embedded software, other than the implementor(s)?


The authors of software which accesses an API/interface to an embedded
system? I think what was intended is that it's easier in C++ than in C to
close off avenues of possible "abuse" - eg. by not exposing data/methods
that should not be accessed by the user of an interface to your system.

>> Much better than anything that you can achieve in C.


I'd prefer "more easily than can be achieved in C".

> Not true. Perhaps you meant to write "I" instead of "you".


Possibly that too

--
Lionel B
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Embedded <divs> with events: How to prevent the parent div's eventfrom being fired when the embedded div's event is fired? Num GG Javascript 2 11-17-2008 08:56 PM
Embedded vs. Non-embedded Tests Trans Ruby 11 09-05-2007 11:22 AM
Embedded languages based on early Ada (from "Re: Preferred OS, processor family for running embedded Ada?") Colin Paul Gloster VHDL 48 04-10-2007 10:31 AM
How to display images embedded in e-mail as embedded, not attachments Jim Firefox 4 12-11-2004 05:36 AM
Databind an embedded control in an embedded datagrid Thomas Dodds ASP .Net Datagrid Control 0 07-26-2004 08:20 PM



Advertisments