NULL pointers

David desJardins desj at brahms
Sun Nov 16 13:32:13 AEST 1986


In article <1696 at ncoast.UUCP> kent at ncoast.UUCP (Kent Williams) writes:
>[...]  It seems supremely asinine that Microsoft C complains about
>
>struct nameless x;
>x = malloc(sizeof(struct nameless));

   Maybe I'm confused, but this seems completely wrong (you are assigning
a pointer to an object).  Do you perhaps mean

struct nameless *x;

?  If so, you should really write

x = (struct nameless *) malloc (sizeof (struct nameless));

as this is what casts are for.  It doesn't seem asinine at all to give a
warning about this.

   -- David desJardins



More information about the Comp.lang.c mailing list