I would agree that it would make sense to avoid the std namespace container classes, etc. The problem is that they are designed to be dynamically resizing and, thus, make use of new ( and subsequently, in most AVR, 'new' implementations, malloc ). Dynamic memory allocation in most any small embedded project is a Bad Idea (tm). One option that I have considered is to rewrite a similar set of collections to be fixed size. I've got a fixed size ring buffer and vector floating around somewhere, and a bitset; they're all tested to be nearly optimal ( certainly close enough given how much they simplify implementation ). But I don't know of a complete set to replace the standard library containers. If the standard containers were replaced though, most of standard algorithms would be able to be used without fear of excessive cost, they do not need the dynamic allocation. Other things in the standard library that are designed for dynamic allocation ( and, therefore are less than ideal for small embedded ) are std::string and the I/O stream classes. I also made fixed size versions of these at one point. While it was not nearly as optimal ( once compiled ) as the container classes above, I, at least, found it satisfying to be able to do all the stream input and output I was used to. The I/O streams, however, did not really match the standard C++ stream API... can't remember now why I broke compatibility! There was some large optimization I could make by not doing things dynamically though... I think... Martin Jay McKee On Thu, Dec 6, 2012 at 9:04 AM, Don Kinzer <dkinzer@gmail.com> wrote: > ** > > > --- In AVR-Chat@yahoogroups.com, "Chuck Hackett" <egroupscdh@...> wrote: > > Is there a place where one can download parts > > of it such as "std::list", etc.? > A Google search turns up several possible sources including: > > http://gcc.gnu.org/libstdc++/ > > That said, I would be very wary of using any std:: code on a device with > severely limited RAM without examining it carefully. I would not be > surprised to find a lot of heap-intensive operations and other issues that > you would probably prefer to avoid. > > You might post a question on AVR Freaks asking about others' experience > using std:: with avr-gcc. > > > Regards, > > Don Kinzer > ZBasic Microcontrollers > http://www.zbasic.net > > > [Non-text portions of this message have been removed]
Message
Re: [AVR-Chat] Re: Mixing gcc C & C++
2012-12-06 by Martin McKee
Attachments
- No local attachments were found for this message.