Linux: C++ In The Kernel?Why Not C++??
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++."
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++."
...全文
相关推荐
Linux系统中安装gcc和kernel-devel的方法
"本文主要介绍了在Linux系统中如何安装gcc和kernel-devel的详细步骤,以及这两个组件在系统中的重要性。gcc是Linux环境下的C/C++编译器,对于安装和开发软件至关重要,而ker
【kernel】——VScode clangd 插件浏览 linux 源码
VScode clangd 插件浏览代码却决于文件生成该文件有很多种方法这里只介绍 bear 和 linux 内核脚本。
cpp binutils gcc glibc-devel glibc-headers glibc-kernheade kernel-headersrs
**cpp**: 这是GNU C预处理器,它处理C或C++源代码,进行宏展开、条件编译等操作,将源代码转化为标准格式,供编译器进一步处理。2.
linux kernel中提取并适配的红黑树的c代码,支持cpp混合环境中编译
这里的"Linux kernel中提取并适配的红黑树的c代码"可能是将Linux内核源码中的红黑树实现进行了封装,以便在非内核环境中使用,例如用户空间的应用程序。
Linux_Kernel核心中文手册(内核图解).pdf,linux内核结构详解,C,C++源码.zip
**C/C++编程基础**:理解内核源码需要扎实的C/C++语言基础。C语言是Linux内核的主要编程语言,而C++在某些模块中也有应用,如设备驱动的模板类。


