Re: linux headers and C++

Nate Tuck (nate.tuck@raycer.com)
Tue, 06 Jul 1999 15:43:13 -0700


At 10:53 PM 7/6/99 +0100, Alan Cox wrote:
>That needs exceptions. You will have a fairly bad time trying to handle
>C++ exceptions in the Linux kernel (apart from the giant table size g++
>outputs you have to deal with interrupts, re-entrant exception handling and
>the like - and of course you have to handle running out of memory in the
>exception handler (yes this last one is foul in C too))

Right, it's a big horrible job. I think that the re-entrancy and interrupt
issues you are bringing up are red herrings though because I'm not
seriously suggesting supporting anything but exceptions synchronously
thrown by the straight line code. Trying to make interrupts into
exceptions is probably just asking for trouble. An alternative is to allow
new to return NULL and train C++ programmers to check all their memory
allocations like C programmers.

My point is that plenty of operating systems have been written in OO
languages, all the problems have been solved before and I'm sure plenty of
people have good ideas on what works and what doesn't in terms of using the
various features of C++. I would hope that nobody who is considering
making C++ work in modules is doing it without reading about previous
experiences with it in kernels of other systems.

I'm not arguing that there isn't a substantial amount of work to be done
both in improving the tools and in training programmers to make it useful.
But there's nothing inherently bad about letting people go off and do that
if it's the only way they want to contribute today. Who knows, maybe
they'll get distracted and work on something else for a while that will do
more than add new language bindings to libkernel ;).

>Writing mainstream kernel code in C++ would IMHO be crazy. Allowing people
>to write C++ modules seems to be quite reasonable.

I agree, I said kernel but I meant module. It sounds to me like you're
willing to take patches, so it will be interesting to see whether the C++
camp is just noise, or whether they start delivering cleanups to you on a
regular basis. I wish them the best of luck.

nate

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/