Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 03-22-2010, 01:49 AM   #1
Registered: Feb 2010
Posts: 30

Rep: Reputation: 15
Question C++ in linux kernel


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.
Old 03-22-2010, 04:01 AM   #2
Senior Member
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Stretch (Fluxbox WM)
Posts: 1,389
Blog Entries: 52

Rep: Reputation: 355Reputation: 355Reputation: 355Reputation: 355
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.

Last edited by neonsignal; 03-22-2010 at 04:03 AM.
1 members found this post helpful.


c++, kernel, linux

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Linux Unified Kernel Aims to Combine Linux, NT Kernel LXer Syndicated Linux News 0 05-28-2009 03:10 PM
LXer: Howto: build Linux kernel module against installed kernel w/o full kernel source tree LXer Syndicated Linux News 0 09-03-2006 09:21 PM
Linux kernel debugging and Linux kernel module programming Igor007 Programming 2 08-13-2005 06:12 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:41 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration