Re: Compiling C++ kernel module + Makefile

From: Michael Clark (michael_at_metaparadigm.com)
Date: 01/21/04

  • Next message: Thomas Molina: "Re: 2.6.1-mm5"
    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).

    http://developer.apple.com/documentation/DeviceDrivers/Conceptual/IOKitFundamentals/About/chapter_1_section_1.html

    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/


  • Next message: Thomas Molina: "Re: 2.6.1-mm5"

    Relevant Pages

    • Re: why kernel in C
      ... This could all be integrated into their very bloOOoated kernel. ... | references and pointers. ... The language I program in for "above C" is Pike, ...
      (comp.os.linux.development.system)
    • Re: Operator overloading in C
      ... All development of C as an independent language has ... making any changes or improvements to the standard ... The lack of a counted string data structure, ... Pointers can't be used for arg1 or arg2. ...
      (comp.std.c)
    • Re: C++ pushback
      ... Haskell is an excellent language, but it is not a system programming ... Kernel programming does not fit well into the functional model. ... a lot of functions/methods have identical names. ...
      (Linux-Kernel)
    • Re: can anyone offer Lisp job?
      ... >> since I'm sure someone will say this argues for turning Common Lisp ... I think the Lisp kernel isn't that much bigger than ... > the Scheme kernel. ... differently because there wasn't the notion of Language As King. ...
      (comp.lang.lisp)
    • Re: pointers?
      ... There's absolutely nothing abstract in pointers. ... Take the C array: if you write ... To the assembly language programmers who were the first generation adopters of C, this mental mapping was very tight. ... Forth gained the most traction on machines like the IBM 1130 and the Data General Nova. ...
      (comp.lang.forth)