From: leathm AT solwarra DOT gbrmpa DOT gov DOT au (Leath Muller) Message-Id: <199703040100.LAA09129@solwarra.gbrmpa.gov.au> Subject: Re: quick malloc question To: fwec AT juno DOT com (Mark T Logan) Date: Tue, 4 Mar 1997 11:00:57 +1000 (EST) Cc: ao950 AT FreeNet DOT Carleton DOT CA, djgpp AT delorie DOT com In-Reply-To: <19970303.162642.7191.0.fwec@juno.com> from "Mark T Logan" at Mar 3, 97 04:30:10 pm Content-Type: text > >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.