Re: FYI: C++ in the core.

From: Last2Know (grokkalot_at_yahoo.com)
Date: 10/30/04


Date: Sat, 30 Oct 2004 13:11:46 -0500

On Sat, 30 Oct 2004 10:38:04 +0200, Ulrich Eckhardt wrote:

> Erik de Castro Lopo wrote:
>> Ulrich Eckhardt wrote:
>>> ... I could well imagine a restricted subset of C++ in the
>>> kernel. In particular things like destructors, namespaces and
>>> type-safety are IMHO lacking,
>>
>> The type safety of c++ is about 0.5% more than the type safety of C
>> with warnings turned on.
>
> GCC will still not warn you when a void pointer is converted to a typed
> pointer (correct me if I'm wrong, I didn't check it), because a void
> pointer in C is a generic pointer, i.e. a pointer that always fits. In C++
> it is a typeless pointer, which converts to nothing without explicit cast.
> There are uses for both types of pointers (e.g. malloc() should return a
> generic pointer, and there are ideas to add such a beast to C++), but
> handling void pointers is inherently error-prone, as it puts all checks up
> to the programmer instead of the compiler.

I'd expect that adding 'const' to the type system in the manner of C++
would be an even bigger help for kernel programming. Also stuff
like making a member variable private/protected and then being able to
easily make a substantive or debugging changes to every access
of that variable in just a few places (though the appropriate
member functions) is a big time saver.



Relevant Pages

  • Re: (maybe DR) lvalueness of dereferencing void*
    ... >> unequivocally refers to a void pointer as pointing to an object. ... that's clearly the only way to interpret it in that particular ... from Stan's original example of dereferencing a void pointer? ...
    (comp.std.c)
  • Re: Passing execution to a memory address
    ... forbidden initialization of function pointer with void pointer ... int add1 ...
    (comp.lang.c)
  • Re: is possible to build some pointer array?
    ... >>>you're saying that a void pointer should not ever point ... > having a value which compares equal to the address of a struct, ... > A void pointer is guaranteed to be able to contain any other kind of object pointer. ...
    (comp.lang.c)
  • Re: re:length_of_my_string+1
    ... >> 6 xlogo ... See below about what execvp() really ... The name of this member is confusing since you don't store a pointer to ... You promised that the function would return a void pointer, ...
    (comp.os.linux.development.system)
  • Re: AfxBeginThread argument is altered
    ... You must never pass in a pointer to a stack local unless you ... essay on worker threads on my MVP Tips site. ... > proper arguments (a void pointer to an array of two casted void pointers to ...
    (microsoft.public.vc.mfc)

Loading