[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: casts considered harmful

Joseph S D Yao writes:
>In general, void pointers are in the language to provide for a mechanism
>to allow a "general pointer" to be passed, which at compile time, of
>course, must be a real pointer.  A real pointer will never be a void
>pointer, and so we use casts.

I'm afraid you don't know much about void pointers.  I suggest that
you spend some time with the C language specification.  void pointers
are malleable pointers that are automatically coerced to ANY pointer
type WITHOUT a cast.

The "void" part there is not a problem.  The "const" part is the problem.
You cannot do a partial cast to make something "just act like a const",
you have to completely cast it and throw out ALL automatic type checking
from the compiler, INCLUDING the checking that what you are passing is
(in this case) a pointer to a pointer.

>Having said that ... the above was just a knee-jerk reaction to your
>paragraph, and I'd have to look at what you were talking about before
>deciding whether it was warranted there.

I'd like to suggest that you actually look at what I am talking about
first, and that you look at what you are talking about, since what you
said neither had any relationship to what I was talking about nor was


"Magazines all too frequently lead to books and should be regarded by the
 prudent as the heavy petting of literature."            -- Fran Lebowitz
 Linux Application Development       http://www.redhat.com/~johnsonm/lad/

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] []