问题描述
我只是好奇,为什么司机和固件几乎一直都是用C语言或汇编语言,而不是C ++?
I am just curious why drivers and firmwares almost always are written in C or Assembly, and not C++?
我听说有这种技术的原因。
I have heard that there is a technical reason for this.
有谁知道这一点?
爱情很多,
路易丝
Lots of love,Louise
推荐答案
由于,大部分时间,操作系统(或运行时库)提供了C语言所需的STDLIB功能++。
Because, most of the time, the operating system (or a "run-time library") provides the stdlib functionality required by C++.
在C和ASM可以创建裸可执行文件,它不包含任何外部依赖性。
In C and ASM you can create bare executables, which contain no external dependencies.
但是,因为Windows不支持C ++ STDLIB,大多数的Windows驱动程序都写在(有限的子集)C ++。
However, since windows does support the C++ stdlib, most Windows drivers are written in (a limited subset of) C++.
此外,当固件写入ASM通常是因为无论是(A),它是在执行没有一个C ++编译器或(B)有极高的速度和大小限制的平台。
Also when firmware is written ASM it is usually because either (A) the platform it is executing on does not have a C++ compiler or (B) there are extreme speed or size constraints.
需要注意的是(B)还没有被完全自2000年初的一个问题。
Note that (B) hasn't generally been an issue since the early 2000's.
这篇关于为什么司机和固件几乎都是用C或ASM,而不是C ++?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!