[prog] School problem, C++ and cout.precision(2);

Robert J. Hansen cortana at earthlink.net
Sat Nov 23 20:31:16 EST 2002


> How come you dont have a single kernel in C++ ?

At one time, my Linux kernel was compiled with g++.  So yes, you do have
kernels written in C++.

I've written device drivers in C++, and those are kernelspace.

One of the big problems with C++ are the fragile base classes.  Any
change to the declaration of a base class requires rebuilding every
class which inherits from it.  As a result, it's generally not a good
idea to represent a kernel as a collection of classes; any change to the
kernel would require you to not only rebuild your kernel, but also
rebuild a lot of your userspace apps.

Another problem is the complex memory management required for
templates.  You rarely mess around with memory yourself when writing STL
code, but STL does a lot of strange memory management
behind-the-scenes.  This gets you into a chicken-and-egg problem when
you're trying to write a kernel memory manager.

As a result, very few people use either templates or objects for kernel
programming.  And once you do away with templates and objects, you might
as well be programming in C.





More information about the Programming mailing list