On 18 Jul 2007, at 22:15, Martin Koller wrote: > >>> IMHO those things should be corrected even for plain C >>> compilation, as >>> it's kind of ugly and might hide bugs. >> >> No, you should not cast the value returned from malloc in C... > > "you should not" in the meaning of "in C it is not needed" or "this > is against > our rules" ? > It would not hurt to still use a cast.
Using a cast can sometimes be bad. For example, lets say I forgot to include <stdlib.h>. The compiler would assume malloc returns an int, as opposed to a void *. This is a problem as on AMD64 systems sizeof (int) != sizeof(void *) and so we could end up with an invalid address. If we are not casting and do: char *c = malloc(1); The compiler will complain, telling us that we tried to cast an int to a char *. If we cast, such as: char *c = (char *) malloc(1); We get no warning about it. I am happy for C++ to be used, but in the same was Giel is for the sound system - C++ with a C API. Something like the network code I do not think will benefit from C++ as much as say the GUI. Regards, Freddie. _______________________________________________ Warzone-dev mailing list Warzone-dev@gna.org https://mail.gna.org/listinfo/warzone-dev