Re: Compiling C++ kernel module + Makefile
From: Michael Clark (michael_at_metaparadigm.com)
Date: 01/21/04
- Previous message: Albert Cahalan: "Re: struct task_struct -> task_t"
- In reply to: Richard B. Johnson: "Re: Compiling C++ kernel module + Makefile"
- Next in thread: Chris Friesen: "Re: Compiling C++ kernel module + Makefile"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 21 Jan 2004 10:24:26 +0800 To: root@chaos.analogic.com
On 01/21/04 02:10, Richard B. Johnson wrote:
>
> Well you just fell into the usual trap of using the "C-like"
> capabilities of C++ to call a 'C' function. If you are going
> to use 'C' library functions, you don't use an object-oriented
> language to call them. That is using a hatchet like a hammer.
>
> I did not malign C++. I used it as it was designed and let
> the chips fall where they may.
Apple has succedded in using C++ in their kernel. Its IOKit uses
an embedded subset of C++ (no exceptions, RTTI, non-trivial
descructors, etc) as part of their device driver framework.
The features they keep; polymorhism, inheritance, encapsulation
provide for a very clean and easily extensible framework.
Writing IOKit drivers is much cleaner than using plain C
without out all the structures with pointers to functions
(explicit implementation of virtual functions and a lot of
casting of (void*) and/or unions).
Although this could all be done in C (as is all the OO stuff in
linux like VFS, block and chardevs, etc), it is certainly much
cleaner in C++.
Although horses for courses, we all know C++ won't fly in
the linux kernel. Just I think 'embedded C++' which is an
actual specification and a genuine superset of C and subset
of C++ retaining safre features for kernels can't be ruled
on on technical merits but rather only on personal opinion
of language choice. Personally i prefer Linux's more explicit
OO implmentation with the use of stuctures with pointers to
functions (virtual functions) although not sure there is a
really clean pattern used for inheritance (unions and void*
private pointers) and encapsulation (static function bounday).
~mc
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
- Previous message: Albert Cahalan: "Re: struct task_struct -> task_t"
- In reply to: Richard B. Johnson: "Re: Compiling C++ kernel module + Makefile"
- Next in thread: Chris Friesen: "Re: Compiling C++ kernel module + Makefile"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|