Why are drivers and firmwares almost always written in C or ASM and not C++?

后端 未结 15 2310
庸人自扰
庸人自扰 2020-12-14 00:22

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.

15条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-14 00:39

    C is very close to a machine independent assembly language. Most OS-type programming is down at the "bare metal" level. With C, the code you read is the actual code. C++ can hide things that C cannot.

    This is just my opinion, but I've spent a lot of time in my life debugging device drivers and OS related things. Often by looking at assembly language. Keep it simple at the low level and let the application level get fancy.

提交回复
热议问题