C++ usage in embedded systems

后端 未结 17 1518
南旧
南旧 2021-01-30 22:45

What features of C++ should be avoided in embedded systems?

Please classify the answer by reason such as:

  • memory usage
  • code size
  • speed<
17条回答
  •  悲哀的现实
    2021-01-30 23:14

    RTTI and Exception Handling:

    • Increases code-size
    • Decreases performance
    • Can often be replaced by cheaper mechanisms or a better software-design.

    Templates:

    • be careful with them if code-size is an issue. If your target CPU has no or only a very tiny ínstruction cache it may reduce the performance as well. (templates tend to bloat code if used without care). Otoh clever meta-programming can decrease the code-size as well. There is no clear cut answer on his.

    Virtual functions and inheritance:

    • These are fine for me. I write almost all of my embedded code in C. That does not stop me from using function-pointer tables to mimic virtual functions. They never became a peformance problem.

提交回复
热议问题