![]() |
C or C++ for Linux kernel Programming
Hi All,
I am new to linux kernel programming. I need to implement some OS kernel bases code. I want to know which one to choose for the programming C or C++. I am inclined to use C++ as this give me code more modularity and OOPs concepts. Is all the libraries of kernel also available in C++? Can some one suggest some IDE for this ? Thanks |
you can use C++ if you cut it back to the basic
so freaky dirived and virtual classes and stuff because all that will have a speed inpact and maybe generate incompatable code C would be more suited but C++ is fine AFAIK |
Quote:
|
coding is always alittle on the harder side in the kernel
i know because the tweeked the $h!t out of the linux kernel and i am writing my own kernel |
Quote:
Can I do one thing write some code in C and some in C++? |
yes
you just dont quite as many services and functions as in user mode |
You cannot use any libraries in the kernel, period. None are supported.
You can use C++ if you wish, but you have to make sure your bindings to the kernel are C style because that is what the kernel is written in. Normally I handle this type of issue by running through some C stubs that are compiled with gcc and that call my C++. Of course, normally I do all my kernel work in C. |
NO!
You cannot use C++ in the linux kernel without a lot of work, and frankly that work doesn't reward with much benefit. C++ implicitly looks for certain bindings to be available. From casts to constructors, C++ just isn't designed to be a kernel language. There's a famous example somewhere of an attempt to do it, but it was really cumbersome and never went anywhere, IIRC. |
Quote:
And your question about availability of kernel libraries "also" in C++ speaks volumes. Programs written in C aren't trivially translated into any other language (except, of course, into machine-specific code by the compiler). Why not just download the kernel source and browse through it? It's not like it's a nuclear secret. |
Quote:
I believe that it IS possible to write kernel code in C++, so long as the C bindings are preserved and no libraries are invoked. Is it a good idea? Probably not. The kernel is written in C and the prudent developer will stick with that. |
| All times are GMT -5. The time now is 03:00 AM. |