Benefits of Embedded Programming in c

C ++ metaprogramming with templates for embedded systems

Bridgehammer

Tobias Kotulla, Dirk Petrautzki

Close to hardware usually means programming specifically for the hardware. Modern C ++, on the other hand, offers more portability with consistently lean binaries.

iX-tract

  • In the very hardware-oriented programming of embedded systems, portability is mostly wishful thinking.
  • With its variadic recursive templates, C ++ metaprogramming offers a way out of the tight hardware link.
  • It is also important to overcome the incompatibilities between the C code parts, for example for handling interrupts, and the C ++ template classes.
  • Despite the increased complexity, the advantages of portability, clarity and maintainability predominate.

Source code that is to be translated on different architectures must be easily portable. However, this is often difficult to achieve in the world of embedded systems. Embedded programming quickly tempts developers to soften the boundaries of clear structuring and to write hardware-specific code, because they are thought to be deep in the hardware level. This complicates or prevents future porting. Modern C ++ offers a way out, which forces developers - when implementing a good basic model - to adhere to clear boundaries and thereby guarantee portability.

With the use of C ++ instead of C and the creation of additional levels of abstraction, the question of possible additional memory requirements and the effect on performance arises. The article shows that with metaprogramming using C ++ templates this fear is unfounded.