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)

Embedded SW uses STL or not的更多相关文章

  1. 微软职位内部推荐-SW Engineer II for Embedded System

    微软近期Open的职位: Do you have a passion for embedded devices and services? &nbsp Does the following m ...

  2. linux(debian) arm-linux-g++ v4.5.1交叉编译 embedded arm 版本的QtWebkit (browser) 使用qt 4.8.6 版本

    最近需要做一个项目 在arm 架构的linux下 没有桌面环境的情况下拉起 有界面的浏览器使用. 考虑用qt 的界面和 qtwebikt 的库去实现这一系列操作. 本文参考: Qt移植到ARM Lin ...

  3. Boost 和 STL 相比有哪些优势和劣势?

    1. 在设计原则上,STL和Boost大体统一因为STL和Boost基本上都是标准委员会那批人在策划.审核和维护,所以口味上是相对接近的.但是因为Boost并不在标准中,或者说是下一代标准的试验场,所 ...

  4. Windows Mobile和Wince(Windows Embedded CE)的字符集问题

    背景 开发过Windows Mobile和Wince(Windows Embedded CE)的开发者,特别是Native C++开发者,或多或少都遇到过ANSI字符集和Unicode字符集的转换问题 ...

  5. linux(debian) arm-linux-g++ v4.5.1交叉编译 embedded arm 版本的QtWebkit (browser) 使用qt 4.8.6 版本 以及x64上编译qt

    最近需要做一个项目 在arm 架构的linux下 没有桌面环境的情况下拉起 有界面的浏览器使用. 考虑用qt 的界面和 qtwebikt 的库去实现这一系列操作. 本文参考: Qt移植到ARM Lin ...

  6. Effective STL 阅读笔记: Item 3: Make copying cheap and correct for objects in containers

    容器 (Containers) 用来存储对象 (Objects), 但是被存储的对象却并非原原本本是你给他的那一个, 而是你指定对象的一个拷贝.而后续对该容器内存储对象的操作,大多也是基于拷贝的. 拷 ...

  7. 《Effective STL》学习笔记

    http://www.cnblogs.com/arthurliu/archive/2011/08/07/2108386.html 作者:咆哮的马甲 出处:http://www.cnblogs.com/ ...

  8. 详细解说 STL 排序(Sort)

    0 前言: STL,为什么你必须掌握 对于程序员来说,数据结构是必修的一门课.从查找到排序,从链表到二叉树,几乎所有的算法和原理都需要理解,理解不了也要死记硬背下来.幸运的是这些理论都已经比较成熟,算 ...

  9. STL标准模板库(简介)

    标准模板库(STL,Standard Template Library)是C++标准库的重要组成部分,包含了诸多在计算机科学领域里所常见的基本数据结构和基本算法,为广大C++程序员提供了一个可扩展的应 ...

随机推荐

  1. java 2D图形绘制

    package jisuan; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.Graphics; imp ...

  2. ubuntu查看占用某端口的程序

    查看端口使用情况,使用netstat命令. 查看已经连接的服务端口(ESTABLISHED netstat -a 查看所有的服务端口(LISTEN,ESTABLISHED) netstat -ap 查 ...

  3. Problem(I) STL - 灵活的线性表

    Description 数组和链表是我们熟知的两种线性结构,但是它们不够灵活(不能同时实现直接插入.删除和访问操作),给你若干种操作,你能通过一种灵活的容器,实现它们的功能吗? 操作1:Build a ...

  4. 强化学习8-时序差分控制离线算法Q-Learning

    Q-Learning和Sarsa一样是基于时序差分的控制算法,那两者有什么区别呢? 这里已经必须引入新的概念 时序差分控制算法的分类:在线和离线 在线控制算法:一直使用一个策略选择动作和更新价值函数, ...

  5. <YaRN><Official doc><RM REST API's>

    Overview ... YARN Architecture The fundamental idea of YARN is to split up the functionalities of re ...

  6. C++面试常见考点

    这两周参加了3家公司的面试,一家是做嵌入式的外企,一家是做智能家居的初创公司,一家是做网络分析的公司. 通过参加面试,越发的觉得语言只是基础,虽然都是计算机领域,但是不同的业务肯能用到的技术不同,所以 ...

  7. golang对数组进行冒泡排序

    什么是冒泡排序? 冒泡排序(Bubble Sort),是一种计算机科学领域的较简单的排序算法. 它重复地走访过要排序的数列,一次比较两个元素,如果他们的顺序错误就把他们交换过来.走访数列的工作是重复地 ...

  8. 创建vue项目

    1.创建项目 vue creat 项目名 // 要提前进入目标目录(项目应该创建在哪个目录下) // 选择自定义方式创建项目,选取Router, Vuex插件 2.启动/停止项目 npm run se ...

  9. Day29作业及默写

    作业: 1\ 默写 黏包协议 2\ 上传大文件(文件\视频\图片) 3\ 和你的同桌调通 从你的计算机上传一个视频到你同桌的电脑上 4\ 进阶 : 带上登录 Server #Server #!/usr ...

  10. python day12 ——1.生成器2.生成器表达式 3.列表推导式

    一.生成器 什么是生成器. 生成器实质就是迭代器. 在python中有三种方式来获取生成器: 1. 通过生成器函数. 2. 通过各种推导式来实现生成器 . 3. 通过数据的转换也可以获取生成器. 1. ...