Mail Archives: djgpp/1997/03/03/20:13:16
> >Why the HELL do people keep writing things like (char
> >*)malloc(x)????????
> >GCC, and to my knowledge other compilers, allow any pointer to be
> >assigned
> >to a variable of type void * and conversely allow any variable of type
> >void
> >* to be assigned to any pointer, without casts.
> This is true, almost any compiler will allow you to do it without cast.
> However, almost any compiler will also give you a warning about it.
> Most people like to keep their code as warning free as possible, so
> they cast pointers.
I also have a lot of code which accesses memory as char's, int's and
long int's...it's nice to be able to tell which type of access I am using
from the cast I have in the malloc when I go back to old uncommented (yeah
yeah, I know) code... :)
Leathal.
- Raw text -