Linux: C++ In The Kernel?Why Not C++??

PaulZhao 2004-04-02 05:18:55
A recent posting to the lkml requested help in porting the C++ Click Modular Router kernel module from the 2.4 stable kernel to the 2.6 stable kernel. The request was for ideas on fixing C++ related compilation errors, but the thread quickly turned into a lengthy debate on whether or not C++ had a place in the Linux kernel. The issue has been debated many times before, long ago earning its own entry in the lkml FAQ which offers numerous reasons why the kernel is not written in C++.

During the recent discussion, when it was suggested that perhaps the kernel is written in C simply because "we've always done it that way...", Linux creator Linus Torvalds joined in to explain:

"In fact, in Linux we did try C++ once already, back in 1992. It sucks. Trust me - writing kernel code in C++ is a BLOODY STUPID IDEA.

"The fact is, C++ compilers are not trustworthy. They were even worse in 1992, but some fundamental facts haven't changed: 1) the whole C++ exception handling thing is fundamentally broken. It's _especially_ broken for kernels. 2) any compiler or language that likes to hide things like memory allocations behind your back just isn't a good choice for a kernel. 3) you can write object-oriented code (useful for filesystems etc) in C, _without_ the crap that is C++."


...全文
65 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
lovejoyboy 2004-04-24
  • 打赏
  • 举报
回复
内核我不清楚,不过软件开发C++还是有优势的,面向对象在快速开发上确实有优势。
君不见,快速开发领域都是面向对象的,C++ Builder,Visual C++,。 C#, Delphi。

eliner 2004-04-24
  • 打赏
  • 举报
回复
关注一下
PaulZhao 2004-04-24
  • 打赏
  • 举报
回复
So in that case,I do prefer C to C++,besides it's simpler though it's really a time-consuming language.
lbaby 2004-04-02
  • 打赏
  • 举报
回复
呵呵,当然,c中也能实现面向对象,如果你看看Linux kernel 的某些代码,就可以明白

再一个,win2k虽说是利用面向对象的方法开法的,
但其内核所用的主要语言并不是c++,而是c

69,369

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧