To: djgpp AT delorie DOT com Subject: Re: quick malloc question Message-ID: <19970303.220414.8255.0.chambersb@juno.com> References: <5fdn2o$mvl AT freenet-news DOT carleton DOT ca> From: chambersb AT juno DOT com (Benjamin D Chambers) Date: Tue, 04 Mar 1997 01:01:08 EST On 3 Mar 1997 05:20:24 GMT ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire) writes: > >"Cristovao Braga" (cbraga AT datasoft DOT com DOT br) writes: >> char *p; >> >> main () >> { >> p = (char *) malloc (5 * 1024 * 1024); >> } > >Why the HELL do people keep writing things like (char >*)malloc(x)???????? Because if you don't, GCC complains. If it complains, you _should_ fix it (although you don't have to, it's good practice). Why do you seem uptight? >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. It is my understanding that gcc complains when you do so. In fact, I believe gcc complains when _anything_ is converted without a cast (although I don't have time to verify - if anyone knows the answer, please let me know if I'm wrong). ...Chambers