Just remember to (a) don't use exceptions (use -fno-exceptions
nowadays), (b) define ::operator new/delete or __builtin_new/delete that
call kmalloc.
On Thu, Aug 20, 1998 at 11:07:46AM -0400, Vladimir Dergachev wrote:
> Why would you want to write driver in C++ ??
Same reason as you'd write anything in C++.
Because you prefer it?
Because you've got some pre-existing C++ which you want to use in a driver?
> If you want OOP just do it in C. Good part of the kernel is done in OOP..
> (look at all the structures with function pointers) and when you write
> something low level you would like to have control over how your objects
> are stored..
1. Not all drivers are low level. The network stack I worked on,
for example, is hardly low level at all yet has the odd bit of
DMA and interrupt handling in it, so part of it has to be a driver.
2. C++ is a wide ranging language with more features than any one person
uses. So I can't speak for everyone. But when _I've_ written C++,
I've been able to do far more sophisticated and _fast_ memory
management, including cache line placement, custom allocators and
optimised inline fast paths, than I've ever done in C.
Similar things are possible in C, and I've done them, but it expands
to such a huge pile of macros, and to much knowledge in the callers
("which memory allocator shall I call for _this_ object") that it
isn't worth the effort for some of the sophistication I've managed in
C++.
Admittedly I did have to hack __builtin_constant_p to work better in
G++ to do this ;-)
3. That said, I consider the kernel an excellent example of OOP in C.
-- Jamie
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html