没有任何理由用C代替C ++进行嵌入式开发? [英] Is there any reason to use C instead of C++ for embedded development?

查看:143
本文介绍了没有任何理由用C代替C ++进行嵌入式开发?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的硬件C ++和C89

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

我在考虑使用C ++使用类,但没有多态性(以避免虚函数表)。
我想用C ++的主要原因是:

I'm thinking about using C++ with classes but without polymorphism (to avoid vtables). The main reasons I’d like to use C++ are:


  • I preFER使用内联的功能,而不是宏定义。

  • 我想我prefixes杂波code使用的命名空间。

  • 我看到C ++位类型更安全,主要是因为模板和详细的铸造。

  • 我真的很喜欢重载函数和构造函数(用于自动铸造)。

做非常有限的硬件(RAM的4KB)开发,当你看到任何理由坚持C89?

Do you see any reason to stick with C89 when developing for very limited hardware (4kb of RAM)?

感谢您的答案,他们是真正的帮助!

Thank you for your answers, they were really helpful!

我想通过这个问题,我会用C坚持,主要是因为:

I thought the subject through and I will stick with C mainly because:


  1. 这是比较容易在C predict实际code和,如果你只公羊4KB,这是非常重要的。

  2. 我的团队主要包含C语言开发,因此先进的C ++功能将不会被频繁使用。

  3. 我已经找到一种方法来内联在我的C编译器(C89)功能

这是很难接受一个答案,你提供这么多好的答案。
不幸的是我不能创建一个wiki和接受它,所以我会选择一个答案让我觉得大多数。

It is hard to accept one answer as you provided so many good answers. Unfortunately I can't create a wiki and accept it, so I will choose one answer that made me think most.

推荐答案

两个原因使用C以上C ++:

Two reasons for using C over C++:


  1. 对于很多嵌入式处理器,无论有没有C ++编译器,或者你必须付出额外它。

  2. 我的经验是嵌入式软件工程师的比例signficant有C ++很少或没有经验的 - 要么是因为(1),或者是因为它往往不被电子engineeering度教 - 所以它会更好坚持使用他们所知道的。

此外,原来的问题,以及一些意见,提4 KB的内存的的。对于一个典型的嵌入式处理器,RAM的量(大部分)无关code尺寸,为code存储,并从闪存中运行。

Also, the original question, and a number of comments, mention the 4 Kb of RAM. For a typical embedded processor, the amount of RAM is (mostly) unrelated to the code size, as the code is stored, and run from, flash.

当然,的code的存储空间量是值得铭记,但随着新的,更广阔,处理器出现在市场上,它不再是一个问题比它曾经是为所有,但最划算敏感的项目。

Certainly, the amount of code storage space is something to bear in mind, but as new, more capacious, processors appear on the market, it's less of an issue than it used to be for all but the most cost-sensitive projects.

在使用C的一个子集+ +的嵌入式系统中使用:现在有一个 MISRA C ++ 标准,这可能是值得一试。

On the use of a subset of C++ for use with embedded systems: there is now a MISRA C++ standard, which may be worth a look.

编辑:查看 的问题,从而导致了关于C对C为嵌入式辩论++系统。

See also this question, which led to a debate about C vs C++ for embedded systems.

这篇关于没有任何理由用C代替C ++进行嵌入式开发?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆