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. SQL-22 统计各个部门对应员工涨幅的次数总和,给出部门编码dept_no、部门名称dept_name以及次数sum

    题目描述 统计各个部门对应员工涨幅的次数总和,给出部门编码dept_no.部门名称dept_name以及次数sumCREATE TABLE `departments` (`dept_no` char( ...

  2. do文件的编写(转)

    以前在使用ModelSim进行仿真的时候,一直是使用其GUI进行操作的,但是这样很繁琐也很费时.故希望学习其自动化仿真do文件,下面是学习的一些总结. 一.编写基本的do文件 下面按照实际仿真的步骤来 ...

  3. matlab中diff的用法

    若是diff(),括号里的元素为向量,那么前一个减后一个即为diff后的结果: 若diff(),括号里的元素为矩阵,那么下一行减上一行即为diff 后的结果:

  4. YLZ开发外网前端

    YLZ外网前端使用的是boottstrap和layer和validform等插件 表格是用boottstrap的tablle加上框架人员开发的ajaxpageresponse进行协调开发 弹窗使用的l ...

  5. ueditor 设置高度height. ue.setHeight(400); 设置宽度 width

    1.引入的文件: <script type="text/javascript" src="../../dist/ueditor1_4_3-utf8-php/uedi ...

  6. Python Algorithms – chapter2 基础知识

    一.渐进记法 三个重要的记号 Ο.Ω.Θ,Ο记法表示渐进上界,Ω记法表示渐进下界,Θ记法同时提供了函数的上下界 几种常见的渐进运行时间实例 三种重要情况 最好的情况,最坏的情况,平均情况 最坏的情况通 ...

  7. String中对字符串进行操作的一些方法

    1.substring 作用:根据字符串下标进行截取 public class StrTest { public static void main(String[] args) { String a ...

  8. Spring Boot 揭秘与实战(五) 服务器篇 - Tomcat 代码配置

    Spring Boot 内嵌的 Tomcat 服务器默认运行在 8080 端口.如果,我们需要修改Tomcat的端口,我们可以在 src/main/resources/application.prop ...

  9. WordPress无插件实现SMTP给评论用户发送邮件提醒

    wordpress中集成PHPMalier给评论用户发送邮件提醒 首先你得去下载PHPMalier.  注:PHPMailer需PHP的socket扩展支持.如果PHPMailer连接邮箱需要ssl加 ...

  10. 餐巾计划问题 zwk费用流解法

    «问题描述:一个餐厅在相继的N 天里,每天需用的餐巾数不尽相同.假设第i天需要ri块餐巾(i=1,2,…,N).餐厅可以购买新的餐巾,每块餐巾的费用为p分:或者把旧餐巾送到快洗部,洗一块需m天,其费用 ...