Re: Linux kernel modules development in C++

From: Horst von Brand (vonbrand@inf.utfsm.cl)
Date: Wed Sep 27 2000 - 14:31:51 EST


=?iso-8859-1?Q?Abel_Mu=F1oz_Alcaraz?= <abel@trymedia.com> said:

> I want to develop a linux kernel module in C++ but I don't find
> makefiles and/or sorce files examples to do this.

Your problem is that you can't use anything of C++ that needs runtime
support inside the kernel (there goes new() and friends), exception
handling is out of the question (bye, bye, throw() et al), and (in case you
hadn't thought of it) libstdc++ is way out of line (no fancy data
structures or algorithms). What is left is not very much... and it won't
make much of a difference in a driver, which by its nature is typically
smallish. You have no place to go to find stuff you could inherit from, so
you'd have to recreate all the supporting object infrastructure in the
kernel in C++, or port it somehow from C (the object model inside the
kernel doesn't really map into C++'s concepts cleanly!). Not worth the
effort, AFAIKS.

The kernel is written in plain gcc C (this is _not_ your ANSI C!), it uses
identifiers that are reserved words in C++. And that won't change anytime
very soon. But that would get you only to the point of using C++'s
procedural aspects. To make it really worthwhile to write parts of the
kernel in C++, the kernel would have to be redesigned from the ground up
for C++. Nobody has ever volunteered (or even just hinted that they could
be persuaded to volunteer) to do this job, and this discussion comes up
each four months or so.

-- 
Dr. Horst H. von Brand                       mailto:vonbrand@inf.utfsm.cl
Departamento de Informatica                     Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria              +56 32 654239
Casilla 110-V, Valparaiso, Chile                Fax:  +56 32 797513
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Sep 30 2000 - 21:00:20 EST