Mail Archives: djgpp/1997/03/03/16:48:16
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)????????
>
>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.
-Fwec
- Raw text -