Mail Archives: djgpp/1997/03/04/01:07:40
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 -