www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/04/01:07:40

To: djgpp AT delorie DOT com
Subject: Re: quick malloc question
Message-ID: <19970303.220414.8255.0.chambersb@juno.com>
References: <B0000041587 AT datasoft DOT datasoft DOT com DOT br>
<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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019