Red Hat Developer Posts Patches As A Baby Step To Converting Linux Kernel To C++

Written by Michael Larabel in Linux Kernel on 1 April 2018 at 07:09 PM EDT. 74 Comments
LINUX KERNEL
Either as an elaborate April Fool's Day prank or the start of something more, longtime kernel developer David Howells of Red Hat has posted 45 patches that begin the work on porting the Linux kernel to build under a C++ compiler rather than C.

David Howells posted the set of 45 patches to "convert the kernel to C++", with these patches fixing real coding issues and targeting the GCC 8.0 C++ compiler. At this stage though the C++ compiler gets as far as compiling init/main.c to a file... Obviously just the tip of the iceberg. These 45 patches have various fixes for the code to clean up arguments, ensuring the code would be happy under a C++ compiler, etc and amount to around one thousand lines of code shifted.

He wrote on the mailing list:
Seriously, though...

Apart from the cleaner inline functions allowed by templating, I'm not sure there's a lot of the C++ language that we would want to use in the kernel unless we want to go for more advanced classes implementing interesting types.

We could, for example, wrap things like userspace pointers, __be numbers, ioport addresses and control access to them that way, but I don't know that it gains a whole load that sparse doesn't give us.

And finally, doing this did find a few minor things that can be fixed.
So this is likely not a real initiative being pursued by Howells or Red Hat, but has uncovered some legitimate minor issues along the way to which there are now fixes for review on the mailing list.


For anyone who doesn't read the Linux kernel mailing list frequently, Linus Torvalds on well more than one occasion has gone off on rants about his distaste for C++... He has gone as far as saying "C++ is a horrible language," so don't expect the kernel to switch over to C++ under his watch. Some developers though have voiced their dissenting beliefs in the past about potential benefits to the Linux kernel in a C++ world.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week