C++ in the kernel

Erik Wikström Erik-wikstrom at telia.com
Mon Jan 5 07:20:03 PST 2009

On 2009-01-05 15:03, Claes Wallin wrote:
> Michael Neumann wrote:
>> This question bugs me since a quite long time so I write it down...
>> FreeBSD had a long thread about pros and cons of using C++
>> in the kernel here [1].
>> I'm undecided whether it would be good to use C++ in the DragonFly kernel.
>> At first, most importantly, there is the question about the quality of
>> the C++ compiler (bug-freeness) and the quality of the generated machine
>> code.
>> I can't answer this for sure, just did a small test compiling
>> the same C code with both a C and a C++ compiler. Both produce the same
>> machine code.. Using C++ classes without all the more advanced stuff 
>> (like exception, RTTI...) shouldn't make too much a difference in the 
>> produced code. So I don't think this will be much of a problem.
> One thing is important to note, which nobody seems to have mentioned so 
> far: C++ without exceptions is, if not impossible, then very very 
> difficult to accomplish. Even "new" throws exceptions.

Unless you tell it to not throw exceptions. If you don't use the
standard library there really is not much that throws exceptions, except
for new. But you would have to provide a different new anyhow so that's
not a problem.

Erik Wikström

More information about the Kernel mailing list