Close
0%
0%

Embedding C++

C++ is an efficient language eminently suitable for use in embedded systems but some look for proof of the efficiency. This is the proof.

Similar projects worth following
[Bjorn Stroustrup] developed C++ from C specifically because he wanted the base to be an efficient language. C is often referred to as 'high level assembly'. [Stroustrup's] goal was to add additional capabilities to C without losing that efficiency. For the most part he succeeded. But even today critics point to various features of C++ and say "That's expensive."

This project is going to demonstrate with code that C++ is suitable for embedded projects. A series of articles on Hackaday.com will discuss the capabilities of C++ that are suitable for embedded systems with code snippets demonstrating the usage. In this project, full code will be presented and discussed.

I invite others to share their experience with C++ on embedded systems. If you've had good results share them. If you've had bad, bring them here and we'll look to see what happened.

Table of Contents for the articles on Hackaday.com

  1. C++ TURNS 30 – LOOKING FORWARD TO THE FUTURE
  2. CODE CRAFT: WHEN #DEFINE IS CONSIDERED HARMFUL - Project Log: Define Considered...
  3. CODE CRAFT: USING ECLIPSE FOR ARDUINO DEVELOPMENT - Project Log: Using Eclipse
  4. CODE CRAFT – EMBEDDING C++: CLASSES- Project Log: Classes - No Code Bloat
  5. CODE CRAFT – EMBEDDING C++: TIMING VIRTUAL FUNCTIONS - Project Log: C++ Virtual Function Calls Are Fast
  6. CODE CRAFT-EMBEDDING C++: HIDDEN ACTIVITIES? - Project Log: What is C++ Hiding?
  7. CODE CRAFT – EMBEDDING C++: TEMPLATES
  8. CODE CRAFT-EMBEDDING C++: HACKING THE ARDUINO SOFTWARE ENVIRONMENT
  9. CODE CRAFT: CROSS COMPILING FOR THE RASPBERRY PI

  • 1 × Arduino Development Environment The development environment for Arduino from http://arduino.cc
  • 1 × Eclipse Arduino Plug-In A plugin to allow Arduino development using the Eclipse IDE. Easiest way to obtain this is from http://www.baeyens.it/eclipse/. If you don't have Eclipse installed there is a download link to install it with the plugin. Otherwise install the plugin to your existing Eclipse installation.
  • 1 × Arduino Uno Code will be demonstrated and timed using a Uno. Sources are arduino.cc, Sparkfun, Adafruit, and many others.
  • 1 × Arduino Due Code will be demonstrated and timed using a Due. It will also be used to demonstrate use of the C++ standard libraries that are not supported by the AVR based Arduinos. Sources are Sparkfun, Adafruit, and many others.
  • 1 × Teensy 3.x Code will be demonstrated and timed using a Teensy 3.x. Sources are arduino.cc, Sparkfun, Adafruit, and many others.

  • What is C++ Hiding?

    Rud Merriam11/20/2015 at 17:22 0 comments

    Developers who are new to or uncertain about C++ become concerned about the many details involved in using classes. Some of those details appear to be hidden costs. Actually C++ brings to light aspects of code that need to be considered. They've always existed but when you create a user defined class you're now responsible for everything. That's what the most recent article CODE CRAFT-EMBEDDING C++: HIDDEN ACTIVITIES? addresses.

  • C++ Virtual Function Are Fast

    Rud Merriam11/13/2015 at 17:46 0 comments

    Virtual functions are not a problem for embedded systems. Their raw performance nearly matches normal C calls and in an overall system performance can actually be a faster. CODE CRAFT – EMBEDDING C++: TIMING VIRTUAL FUNCTIONS measures C function calls, C pointer to function calls, and C++ virtual calls and finds them taking the same amount of time, for pratical purposes.

  • Using Classes - No Code Bloat

    Rud Merriam11/06/2015 at 18:24 0 comments

    This article CODE CRAFT – EMBEDDING C++: CLASSES provides a short overview of C++ classes. It compares the code size for equivalent C and C++ versions of Arduino Uno and Due code. The finding is that classes do not increase the size of the code, which is what the article was intended to show.

  • Using Eclipse

    Rud Merriam10/31/2015 at 03:15 3 comments

    The Arduino IDE has limited capabilities. It is basically a text editor with some additional capabilities to add the tool chains for various Arduino boards and call them to build the executable.

    An alternative is Eclipse since it has a plugin that uses the Arduino directories to control the Eclipse project. But Eclipse adds many capabilities for working with C++ (and C!) that make it a better choice than the Arduino IDE. If you have features of Eclipse that you like that weren't mentioned that's what comments are for.

    There are other options to chose from and the article's comments list some of them. I'll try to remember to make a list of them somewhere in this project. Feel free to add comments here about other IDEs. No flame wars, please. Just factual descriptions of what works, how well, etc.

    I'm going to be using Eclipse since I am used to working with it.

  • #Define Considered...

    Rud Merriam10/31/2015 at 03:10 0 comments

    This article is not directly related to this Embedding C++ project. It was written before the project began. But it is applicable because when switching to C++ the need to use macros (#define) is reduced considerably. As the article mentions, this was a specific goal of Bjarne Stroustrup as he developed the language.

View all 5 project logs

Enjoy this project?

Share

Discussions

Wassim wrote 07/17/2020 at 18:21 point

This is a very basic yet interesting Topic. I wouldn't have thought that c++ still have to prove itself in embedded since it's in the industry since a while. In the sake of completeness, when talking about embedded C++, especially in hobbyist DIY environment, I would make a standing ovation for Arduino (I've seen you've mentioned it on some posts), which has proven that c++ is actually much easier to use so that many start using c++ without even realizing. Also arm mbed worth a mention as it's highly c++ properly wrapped.

Where is this going ? I would end up by wondering if garbage collection should not be something that we should count on ? That c++ has skipped. And finally checking all the ground won by python in terms of practicality not to replace c++ (not at all), but replacing what python can do with c++ is a useless pain.

Last but not least, there is embedded and there is embedded, if it's a TV set c++ it would not be the same as a space rocket c++. Some embedded systems could use a subset of c++ excluding all dynamic memory allocation, and for a reason. I guess the goal of this initiative would be to embed all of the c++. The issue in dynamic memory allocation relates more to the verification tools and processes, it's easier to automatically verify c than c++, and especially cheaper. Using c++ without exceptions is something that c++ defenders find as an oddity, yet convincing safety fanatics to use exceptions is indeed a challenge. I like this project and I'd support it :)

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates