LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 03-22-2010, 12:49 AM   #1
ravishekhar.82
Member
 
Registered: Feb 2010
Posts: 30

Rep: Reputation: 15
Question 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.
 
Old 03-22-2010, 03:01 AM   #2
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Jessie (Fluxbox WM)
Posts: 1,388
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 03:03 AM.
 
1 members found this post helpful.
  


Reply

Tags
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 02: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 08:21 PM
Linux kernel debugging and Linux kernel module programming Igor007 Programming 2 08-13-2005 05:12 AM


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

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