Is there any reason to use C instead of C++ for embedded development?

后端 未结 30 3680
既然无缘
既然无缘 2020-11-30 17:20

Question

I have two compilers on my hardware C++ and C89

I\'m thinking about using C++ with classes but without polymorphism (to avoid vtables). The main r

30条回答
  •  日久生厌
    2020-11-30 18:06

    In general no. C++ is a super set of C. This would be especially true for for new projects.

    You are on the right track in avoiding C++ constructs that can be expensive in terms of cpu time and memory foot print.

    Note that some things like polymorphism can be very valuable - the are essentially function pointers. If you find you need them, use them - wisely.

    Also, good (well designed) exception handling can make your embedded app more reliable than an app that handles things with traditional error codes.

提交回复
热议问题