As the complexity increasing of embedded software, more and more projects/products use C++ as the implementation language.  Firstly, I want to make a conclusion which applied in our company.

  • Using C++ for a stronger MCU like 32bit MCU like panel, gateway, etc.
  • Using C for 8bit MCU mostly like detector, input module, etc.

We can use the strong features of C++ to implement for time and cost saving, like object-oriented design, encapsulate, polymorphic, template, libraries, design pattern, etc. but some features, we shall be careful, for example STL. Also conclusion listed here.

  • For Linux OS used system, we can use STL freely.
  • For RTOS, we deny to use STL.

The considerations of using STL or not are the memory management, code size, performance, etc.  I can list the cons below.

  • Dynamic memory allocation are used
  • STL allocators are slow, bloated, low performance
  • Inline function increase the code size, not all compiler do the optimization very well

As we known, the No.1 rule of embedded development special for real time embedded is allocating memory “in-front”.

In conclusion, the C++ features shall be applied judiciously. Whether or not, depend on the balance of cost/effort, experience, etc.

By the way, why not use C++ to write the Linux Kernel? What’s the answer from Linus Torvalds: writing kernel code in C++ is a BLOODY STUPID IDEA. The fact is, C++ compilers are not trustworthy. The whole C++ exception handling thing is fundamentally broken. It's _especially_ broken for kernels. Any compiler or language that likes to hide things like memory allocations behind your back just isn't a good choice for a kernel.” (quoted in the linux-kernel FAQ)

最新文章

  1. 剑指Offer面试题:35.将字符串转换为数字
  2. IOS 消息机制(NSNotificationCenter)
  3. SpringMVC常用注解實例詳解1:@Controller,@RequestMapping,@RequestParam,@PathVariable
  4. percona-toolkit系列之介绍和安装(mysql复制工具)
  5. unity3d模型制作规范
  6. 单源最短路_SPFA_C++
  7. 了解Git
  8. 【Android 界面效果13】关于全屏和取消标题栏
  9. innodb对update的处理
  10. C# 的 WCF文章 消息契约(Message Contract)在流(Stream )传输大文件中的应用
  11. HDU 3117 Fibonacci Numbers(围绕四个租赁斐波那契,通过计++乘坐高速动力矩阵)
  12. SVG六基本元素
  13. [转帖]NUMA架构的CPU -- 你真的用好了么?
  14. sklearn countvectorizer坑
  15. c# 泛型和IComparable<T>接口
  16. 【题解】 [ZJOI2006]书架 (Splay)
  17. SQL 中 replace 替换字符串中的字符 ''
  18. redis安装出错
  19. window 窗口编辑
  20. Quadro P5200 - 最强大的移动工作站显卡 专门为了惠普 VR Z 背包电脑而发布

热门文章

  1. vivado对task和function的可综合支持
  2. freemarker学习 (servlet + freemarker -> Struts2+freemarker -> springMVC+freemarker)
  3. matlab中hold on 和hold off功能的区别
  4. tf 版本更新 记录
  5. POJ - 2823 Sliding Window (滑动窗口入门)
  6. static关键字(修饰函数、局部变量、全局变量)
  7. 2017-2018-2 20165214 实验四《Android开发基础》实验报告
  8. angular 学习日志
  9. JAVA_关键词01_instanceof的应用
  10. "@P0"附近有语法错误解释及定位修复