C++ on Small-Footprint Microcontrollers

后端 未结 6 2202
隐瞒了意图╮
隐瞒了意图╮ 2020-12-05 00:39

It seems to me people consistently shy away from, or rather vehemently oppose the use of, C++ on microcontrollers, but I can\'t for the life of me figure out why. If you sta

6条回答
  •  醉酒成梦
    2020-12-05 01:18

    In C++ you essentially only pay for what you use over and above what would otherwise be C compilable code, and some of the extras are cost free.

    The biggest issue with some C++ compilers for small targets is the completeness of available C++ implementations or the availability of a C++ compiler at all.

    EETimes/Embedded.com has run a number of articles on the subject over the years:

    • Better even at the lowest levels - Dan Saks
    • Embedded C++ Yields Faster Smaller Code - John Carbone
    • Why C++ is a viable alternative to C in embedded systems design - Fergus Bolger
    • Poor reasons for rejecting C++ - Dan Saks
    • Using C++ Efficiently in Embedded Applications - Mentor Graphics/Cesar A. Quiroz
    • The Inefficiency of C++ , Fact or Fiction? - IAR Systems/Anders Lundgren

    The point most of these articles make is that you should not necessarily use all of C++ in an embedded system and they measure or explain the cost in terms of memory, speed, and determinism of various features. What parts you use will depend on the nature of your application (whether it has real-time constraints for example), and the available resources and performance of your target platform.

提交回复
热议问题