Modern C++ and embedded programming

I am wondering how many of the modern (C++11 and later) features would you consider usable for embedded programming.

The majority of the code I have seen so far can be written as plain C. I rarely see use of smart pointers, lambdas, templates and standard libraries. Even some of the classic features such as dynamic allocation and inheritance are almost never used.

I have found the C++ as C approach usually works as long as the main module is no longer than 500 lines. After that it becomes quite hard to determine the logic. This is especially true when reading code that implements state machines.

I guess at my main question is a what point would you consider using abstraction (even as simple as namespaces and classes) in your embedded code? Is there any case where you would use any modern C++ features?

Thanks

1 Like

Check out:

and the reddit discussion of it:
https://www.reddit.com/r/embedded/comments/14av0s1/modern_c_in_embedded_development_dont_fear_the/?rdt=38584

Bjarne Stroustrup was quite conscious of the overhead associated with various features and made quite an effort to insure that you don’t have to ‘pay’ for advanced features you don’t use.

1 Like