LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   C++ in linux kernel (https://www.linuxquestions.org/questions/linux-newbie-8/c-in-linux-kernel-796977/)

ravishekhar.82 03-22-2010 12:49 AM

C++ in linux kernel
 
Hi,

First of all I don't want to go discussion regarding C v/s C++ in Linux kernel etc.

I just wanted to know or find out that is there any way available or possible that I can use C++ in my Linux kernel.

Anyone having some suggestion.

neonsignal 03-22-2010 03:01 AM

Since C++ has the same underlying call structure and uses the same linker, there is no fundamental reason why you can't use C++ for kernel code.

However, there are a number of areas that require some thought:
  • Calls to and from the C code will require the use of 'extern "C"' to prevent name mangling so that linking will succeed.
  • If you need to use heap space, you will need to write your own new and delete to be compatible with the kernel (ie, making use of kmalloc).
  • You will have to be careful about the use of libraries (including the standard ones); many will not be safe to use in a kernel context.

Since the bulk of the operating system is not object oriented, I'm not sure you would gain much by using C++ apart from some minor language improvements.


All times are GMT -5. The time now is 05:46 AM.