473,804 Members | 3,209 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

I want to produce a piece of software for embedded systems, generally
telecoms based, mostly running on ARM processors, but I can't guarantee
that, of course.

My software should work along with other software which will generally
be written in C or C++ (occasionally in ADA or even assembler).

I suppose that there are C compilers for marginally more processors
than C++, but, realistically, I am not sure that it makes a major
difference.

I suppose that C produces slightly smaller and faster code, but wonder
if it makes a major difference.

I like C++ exception handling (but know 6that it adds an overhead). I
have clearly defined interfaces and interfacing software would gain
nothing really by instantiating any classes, if I used C++

I want to genericize functionality which the host software ought to
provide, so that I can use their memory allocation routines, timers,
debug tracing, etc, etc - probably just by offering some #defines,
which they can change in a single header file, as necessary - but any
advice is welcome.

I think that I am leaning towards C, but am open to input ...

Thanks in advance for any help.

Jan 3 '07
42 2372
On Fri, 5 Jan 2007 04:57:31 -0600, jacob navia wrote
(in article <45************ **********@news .orange.fr>):
santosh a écrit :
>jacob navia wrote:
>>CBFalconer a écrit :

jacob navia wrote:
... snip ...
That's why I inroduced references in lcc-win32 C compiler

How do you disable them, and ALL the other extensions?
No need to disable them, since you use them only if
you explicitely write
int &a = b;

You just do not use that.


But there should be a mode in which the compiler produces a diagnostic
and possibly halts compilation for sources having non-C90 and/or
non-C99 constructs.

For lcc-win32 what are the switches or flags which turn on this
behaviour?

Yes. Use the -ansic switch
Which generates C89? Is there something for ISO standard C?

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

Jan 10 '07 #41
On Thu, 4 Jan 2007 07:56:11 -0600, Henryk wrote
(in article <11************ *********@i15g2 000cwa.googlegr oups.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

Jan 10 '07 #42
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 <11************ *********@i15g2 000cwa.googlegr oups.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
Jan 10 '07 #43

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
342
by: Peter Zentner | last post by:
Hi, I have a bitmap as an embedded resource. Now I want to use that bitmap for a background image of a button. But if I do the following it doesn't work. <snap start> Dim s As System.IO.Stream = Me.GetType().Assembly.GetManifestResourceStream("WindowsApplication1.Bitmap1 ..bmp") Dim bmp as bitmap = New Bitmap(s)
2
2201
by: | last post by:
Where can I find a minimal version of python (less than 2 MB) suitable for a web server on an embedded linux system? The small size is required because the system lives on flash memory. Thanks, Ken Seehart
2
12171
by: Jani Mantytorma | last post by:
I have embedded resource called Settings.xml. I'm able to read the resource but how can I write data to the resource. The code for read operation follows: private XmlDocument m_doc = new XmlDocument(); System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly(); System.IO.Stream stream = a.GetManifestResourceStream(this.GetType(),"Settings.xml"); if(!(null==stream)) { System.IO.StreamReader rdr = new...
2
1895
by: Kyle Kaitan | last post by:
I have an assembly (AppResources.dll) which contains a number of embedded resource files. Most of these are key/value pairs of relevant strings; a few are images and sounds; some more are XML files. My application will load the resources into memory as they are needed. I would like to be able to read and write to these embedded resources. Is it possible to write to an embedded resource within an assembly? If so, how? If it's not...
0
2352
by: BattleAngel444 | last post by:
Hi All I am trying to run the Postgres 8.0 intaller on my XP embedded (XPe) build. I get to the point where it runs initdb.exe but it ends up failing and does not install. I believe i am possible missing a system file or service but i don't know. To me it seems like the postgres installer comes with its own system files. below is a link to a thread with what i believe is the same problem. ...
0
6504
by: garethrichardadams | last post by:
Hello all, I've added a font to my project and set it to "Embedded Resource". I load the font into a global PrivateFontCollection. (InitCustomFont - shown below) I then set the font of a label to be equal to the custom font (SetCustomFont - shown below)
2
1381
by: Peter van der veen | last post by:
Hi I have a VB project and added a text file to it as an embedded resource. But i can'f find a way now how to read this file just as a normal text file with the streamreader command. Anyone can give me a hint?
1
1928
by: mark | last post by:
I'm using System.Net.Mail to send HTML email. I have a few images embedded within the HTML body. What's the most efficient way of including these images with the message or getting the images to display on recipient's client? Obviously, I want to avoid spam filters and don't want to hog bandwidth. Any help much appreciated.
7
34932
by: Morias | last post by:
I have been trying to install a Zebra LP2844 on a computer running Windows XP. When using the add printer wizard I get an error that simply tells me "The printer could not be installed," but when using the plug and play auto detect wizard I get the error "Data area passed to a system call is too small." The printer has worked on this particular computer before, but when it started malfunctioning I tried reinstalling the drivers and that is when...
4
6392
by: tvnaidu | last post by:
Porting small application from windows to embedded system, not decided what to use whether RTOS or Embedded Linux, is there big difference between RTOS and embedded Linux?. also I need to reduce the C code size (during development all debugging symbols are visible), for final product, I don't need all debugging symbols, I need to turn off all those symbols, can I reduce code size for final product?. also I have to write a library which...
0
9708
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9587
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10588
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10340
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7623
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6857
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5662
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4302
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3827
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.