473,796 Members | 2,512 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C++ STL in embedded systems

Are there any restrictions/problems for use of C++ STL in development
in embedded systems?
In particular:
* Does STL require too much space/memory?
* Is 'implementation of STL algorithms/methods' reenterable/reentrant?
* What is the cost to provide continuity of vectors in memory?
Any other problems?

--
Alex Vinokur
email: alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn

Jan 3 '06
49 8975
"mlimber" <ml*****@gmail. com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
As to conformance, I don't know that I've run across a fully conformant
compiler/runtime yet.


No fully conformant compiler cum library exists, though some are close
and are available on a wide variety of platforms (GNU, Comeau, etc.).


Uh, the EDG front end has been fully compliant for several years
now, and the Dinkumware C/C++ library has been for even longer.
Since we have a number of OEM customers in common, integrated
fully conforming C++ compilers do exist. You can also paste together
your own by licensing Comeau C++ (which uses EDG) and our library.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
Jan 4 '06 #21
P.J. Plauger wrote:
"mlimber" <ml*****@gmail. com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
As to conformance, I don't know that I've run across a fully conformant
compiler/runtime yet.


No fully conformant compiler cum library exists, though some are close
and are available on a wide variety of platforms (GNU, Comeau, etc.).


Uh, the EDG front end has been fully compliant for several years
now, and the Dinkumware C/C++ library has been for even longer.
Since we have a number of OEM customers in common, integrated
fully conforming C++ compilers do exist. You can also paste together
your own by licensing Comeau C++ (which uses EDG) and our library.


I stand corrected.

Cheers! --M

Jan 4 '06 #22
"JustBoo" <Ju*****@BooWho .com> wrote in message
news:85******** *************** *********@4ax.c om...
On 3 Jan 2006 10:47:05 -0800, "Alex Vinokur"
<al****@users.s ourceforge.net> wrote:
Are there any restrictions/problems for use of C++ STL in development
in embedded systems?


Hey look what I just found, from their website:

The Dinkum EC++ Library as specified by the Embedded C++ Technical
Committee. (See the Dinkum EC++ Library.) This is far and away the
most widely used EC++ library in the embedded programming community.

http://www.dinkumware.com/libdual_vc.html

Good Luck.


Right, and if you really want:

-- STL

-- namespaces

-- exceptions

you also get our Abridged library, in the same package, that
extends EC++ with each of these three optional features.
Many embedded C++ compilers ship with this library.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
Jan 4 '06 #23

P.J. Plauger wrote:
[snip]
you also get our Abridged library, in the same package, that
extends EC++ with each of these three optional features.
Many embedded C++ compilers ship with this library.

[snip]

Does 'Green Hills C++ Compiler' use your Abridged library?

Alex Vinokur
email: alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn

Jan 4 '06 #24
"Alex Vinokur" <al****@users.s ourceforge.net> wrote in message
news:11******** *************@g 14g2000cwa.goog legroups.com...
P.J. Plauger wrote:
[snip]
you also get our Abridged library, in the same package, that
extends EC++ with each of these three optional features.
Many embedded C++ compilers ship with this library.

[snip]

Does 'Green Hills C++ Compiler' use your Abridged library?


Yes. They also ship our full C++ library as well.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
Jan 4 '06 #25
|| If you know how big it will grow (or even approximately how big),
you
|| can use std::vector<>:: reserve() to set the initial capacity, which

|| will help minimize copying. If you do not know how big the size
will
|| grow and std::vector's memory allocation scheme doesn't work well
for
|| your system, you should probably not use them.

When dealing with embedded systems there seems to be a lot of fuss (
the word - which I'm opting to change - on the street in my world is:
Avoid it, unless absolutely necessary) about the use of the C++
Standard Library ( most still refer to it as STL ). Language
linguistics aside, the worse case scenario here amounts to not knowing
how big a size required. But even so. With a C style array, the C
solution mirrors that of _allocating_ a large chunk of vector memory.
More memory than I might need. Am I missing something?

IOW: (i dont know how much memory I'll need). Well:

int *ptr_mem = new int[some_large_valu e]; // leave it for good -
hope to - whatever you believe in - it's enough.
or
int arr[some_large_valu e];

vector<int> myVec( some_large_valu e, 0 ); // leave it. may or may
not need some large value but hope to god it's enough.

Jan 4 '06 #26
Alex Vinokur wrote:
Are there any restrictions/problems for use of C++ STL in development
in embedded systems?

....

If you need an ordered associative container that doesn't require
elements to be copied into a general-purpose heap, consider:

http://www.geocities.com/wkaras/gen_cpp/avl_tree.html

At the other end of the spectrum, if your embedded system runs Linux
(or some other OS with per-process memory protection and explicit
shared memory), and you need to create an STL Allocator for shared
memory, this code (in straight C) may be a useful starting point:

http://www.geocities.com/wkaras/heapmm/heapmm.html

All of the above code is designed to be reentrant.

Jan 4 '06 #27

P.J. Plauger wrote:
"Alex Vinokur" <al****@users.s ourceforge.net> wrote in message

[snip]
Does 'Green Hills C++ Compiler' use your Abridged library?


Yes. They also ship our full C++ library as well.

[snip]

Is 'implementation of STL algorithms/methods in Extended Embedded C++'
reenterable/reentrant?

Thanks.

Alex Vinokur
email: alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978

Jan 5 '06 #28

P.J. Plauger wrote:
"Alex Vinokur" <al****@users.s ourceforge.net> wrote in message

[snip]
Does 'Green Hills C++ Compiler' use your Abridged library?


Yes. They also ship our full C++ library as well.

[snip]

Is 'implementation of STL algorithms/methods in Extended Embedded C++'
reenterable/reentrant?

Thanks.

Alex Vinokur
email: alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978

Jan 5 '06 #29
ma740988 wrote:
|| If you know how big it will grow (or even approximately how big),
you
|| can use std::vector<>:: reserve() to set the initial capacity, which

|| will help minimize copying. If you do not know how big the size
will
|| grow and std::vector's memory allocation scheme doesn't work well
for
|| your system, you should probably not use them.

When dealing with embedded systems there seems to be a lot of fuss (
the word - which I'm opting to change - on the street in my world is:
Avoid it, unless absolutely necessary) about the use of the C++
Standard Library ( most still refer to it as STL ). Language
linguistics aside, the worse case scenario here amounts to not knowing
how big a size required. But even so. With a C style array, the C
solution mirrors that of _allocating_ a large chunk of vector memory.
More memory than I might need. Am I missing something?

IOW: (i dont know how much memory I'll need). Well:

int *ptr_mem = new int[some_large_valu e]; // leave it for good -
hope to - whatever you believe in - it's enough.
or
int arr[some_large_valu e];
Right. Many of the same problems with growing a std::vector apply
equally to all other array-ish constructs. The main issue for embedded
systems, as I see it, is that std::vector grows exponentially, which
may be unacceptable or undesirable in some circumstances.
vector<int> myVec( some_large_valu e, 0 ); // leave it. may or may
not need some large value but hope to god it's enough.


You probably want to use reserve instead of allocating that many
elements straight away.

Cheers! --M

Jan 5 '06 #30

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

Similar topics

12
3104
by: Brandon | last post by:
Java seems to have taken off as the platform and language of choice for many embedded devices. Would it be feasible for Python(perhaps running on an embedded version of Linux) to act in such a capacity. Most of my experience with Python has been with Unix-type scripting tasks and using it when it is an applications built in scripting, but I know some people try to use to build larger complex applications. Is the Python interpreter portable...
12
2984
by: Bill Hanna | last post by:
C is inadequate for embedded systems for the following reasons: 1) Direct addressing of memory mapped I/O is not supported simply and easily. You have to find work-arounds that are compiler dependent. You have to create macros , use casting and use indirect addressing (pointers) to read or write to memory mapped I/O. 2) C does not support real time interrupts. The interrupt vectoring is compiler dependent.
10
2521
by: Alex Vinokur | last post by:
The memory allocation issue in embedded systems is usually critical.. How can one manage that? 1. Via 'new' char* p = new (nothrow) char ; if (p == 0) { // He we know that it is impossible to allocate the requested memory // We can do something relevant.
20
22544
by: Jack | last post by:
Is there a Python packaging that is specifically for embedded systems? ie, very small and configurable so the user gets to select what modules to install? For Linux-based embedded systems in particular? I'm thinking of running it on the Linksys's Linux-based open source router WRT54G. It has 4MB flash and 16MB RAM. I think another model has 16MB flash. Any possibilities of running Python on these systems?
0
2271
by: YellowFin Announcements | last post by:
Whitepaper: "Yellowfin Reporting" enables Embedded Business Intelligence -------------------------------------------------------------------------------- Embedded reports are a standard requirement of most applications. But users are increasingly demanding more sophisticated reporting from applications - seeking such features as custom report design, ad hoc report creation and analytics. Developers that want to embed business...
2
1311
by: pdeivanayagam | last post by:
hi i hav cmpltd my engg.i am thnkng of doing an embedded systems. course...can i knw abt prospect of embedded systems?wut will be the oppurtunities available in embedded systems?i want some infm reg this.can anyone guide me reg this? regards deivanayagam
14
1898
by: Martin Wells | last post by:
When I want to store a number, I use "unsigned". I go with unsigned because it's the natural type for the system, and so should be the fastest. However, there are 8-Bit microcontrollers out there that do 8-Bit arithmetic faster than 16-Bit arithmetic, and so on these systems char is faster than int. Standarising C in such a way that int is at least 16-Bit, has this made C both slow and memory-hungry for embedded systems programming?
20
2055
by: =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
There are a few guarantees I exploit in the C Standard. For instance, I might write (unsigned)-1 to get the maximum value for an unsigned integer. Also, I might rely on things such as: memset(data,-1,sizeof data)
30
4303
by: =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
Let's say we had a simple function for returning the amount of days in a month: unsigned DaysInMonth(unsigned const month) { switch (month) { case 8: case 3: case 5:
0
9673
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
9525
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
10452
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
10221
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
10169
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5440
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5569
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4115
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
3
2924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.