Messages in this thread | | | Subject | Re: C++ in kernel (was Re: exception in a device driver) | From | Nathan Myers <> | Date | Thu, 7 Jan 1999 18:15:15 -0800 |
| |
Alan Cox wrote: > For C++ without exceptions you need to provide the 'new' and 'destroy' > operators - probably using kmalloc, and since a performance tuned piece > of C++ isnt going to gratutiously create/destroy objects it should all > work fine.
You don't need "new" and "delete" to run C++ code. kmalloc is fine, as-is, though an (inline) type-safe wrapper would improve it.
> > Ben Scherrey wrote: > > Just using it as a "better C" rather than bringing all its features in > > at once would make for a cleaner system and extend ... > > Been there, done that, didnt like it threw it out. There were several > problems that came up. Firstly the resulting code was less efficient - > that is partly the compiler but does seem to be at least fractionally > the language - its very hard to figure out in C++ when you can avoid > passing 'self' around for example.
The last time it was tried was with a four-year-old compiler, gcc-2.7. Egcs has improved a great deal since that trial.
The rest is FUD: it's trivial to "figure out" when you are passing a "self" pointer argument around: only non-static member functions have them.
> Linux is very much object oriented especially at the device/filesystem > sort of level. It just does its methods via C and C function vectors. > There is a joke that C is nothing more than a portable assembler. To > an extent its true and for an OS kernel thats a feature not a flaw.
You cannot compare C++ to C on a low-level efficiency basis; given modern compilers they are precisely equivalent for any comparable operation.
But... there's no point in arguing it here. When modules are written in C++ and demonstrated to be equally efficient and more maintainable, then everyone will agree that they always believed C++ would be fine for kernel code once a few things got cleaned up.
The only thing to do now is to clean up headers. Will Linus accept patches in 2.3 whose sole purpose is to clean up incompatibilites with Egcs g++?
Nathan Myers ncm@cantrip.org
- 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.tux.org/lkml/
| |