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. POJ - 2635 E - The Embarrassed Cryptographer

    The young and very promising cryptographer Odd Even has implemented the security module of a large s ...

  2. shell中环境变量

    Linux中环境变量包括系统级和用户级,系统级的环境变量是每个登录到系统的用户都要读取的系统变量,而用户级的环境变量则是该用户使用系统时加载的环境变量. 所以管理环境变量的文件也分为系统级和用户级的, ...

  3. 7.Python 正则表达式学习笔记

    本文介绍了Python对于正则表达式的支持,包括正则表达式基础以及Python正则表达式标准库的完整介绍及使用示例.本文的内容不包括如何编写高效的正则表达式.如何优化正则表达式,这些主题请查看其他教程 ...

  4. Python代码 注释

    对某些代码进行标注说明,增加程序的可读性. 一.单行注释 以“#” 开头,#后面的所有东西都不会被运行 print("hello python") # 输出 `hello pyth ...

  5. mysql解决数据库高并发

    分表分库 数据库索引 redis缓存数据库 读写分离 负载均衡: 将大量的并发请求分担到多个处理节点,由于单个处理节点的故障不影响服务,负载均衡集群同事也实现了高可用性.

  6. python 一行代码字符串转字典方法

    b = 'bid=Qzw9cKnyESM; ll="108288"; __yadk_uid=4YChvgeANLBEh4iV00n1tc0HQ8zpmSl1; __utmc=301 ...

  7. Python 爬虫的工具列表大全

    Python 爬虫的工具列表大全 这个列表包含与网页抓取和数据处理的Python库.网络 通用 urllib -网络库(stdlib). requests -网络库. grab – 网络库(基于pyc ...

  8. Linux命令--1

    之前一直在学习Linux,不过有点一天打鱼两天晒网的意味,现在希望通过写博客的形式,积累更多的知识,也希望可以帮到同在linux坑中的各位小伙伴们~ PS:我的笔记重点在于通俗,很多命令一百度就有,但 ...

  9. Android Hook框架adbi源码浅析(一)

    adbi(The Android Dynamic Binary Instrumentation Toolkit)是一个Android平台通用hook框架,基于动态库注入与inline hook技术实现 ...

  10. Foxmail软件添加QQ邮箱报错

    #报错现象: -ERR Please using authorized code to login. More information at http://servi 请使用授权代码登录.http:/ ...