[LCP]Rounding questions

Josh Helmer jhelmer4 at cox.net
Mon Sep 9 03:16:05 UTC 2002


>
> As you know, malloc() returns a `void *'.  It is automatically
> converted to a `struct foobar *' by the above assignment and
> there is no need, in this case, for a cast (and there are good
> reasons for saying that a cast here is `wrong').
>


Sorry... I feel like a dumbass for having spent so much time defending my own 
ignorance.  I knew that you didn't have to cast the return from malloc (and I 
don't), but never made the connection that you could just assign a void 
pointer to any type of pointer in other cases too...  I went back and wrote 
some quick test code and lo-and-behold the casts that I had always believed 
were necessary were not...  Oops..

I'll just slink back to my corner and sit quietly now...

Josh




More information about the linuxCprogramming mailing list