null pointers
Posted Mar 19, 2008 21:11 UTC (Wed) by
vmole (guest, #111)
In reply to:
null pointers by tialaramex
Parent article:
Who maintains dpkg?
Because it's not a matter of narrow vs. wide, or using something "narrower than (void *)". If the function specification says "This vararg list is terminated by null character pointer", then, by the standard, you have to pass something equivalent to "(char *) 0", and "(void *) 0" isn't. The idea of a "void *" being generic is that variables of type "void *" can store pointers of any type, and pointers can be cast to void and then back to the original type without information loss. But they are a distinct type, and not necessarily interchangeable with other pointer types.
Does this matter the vast majority of the time? No. Is it C standard lawyer nitpickery of the most annoying kind? Yes, of course. But the C89 standard is this way precisely because there were some systems for which this kind of nitpicking *did* matter.
But yes, where you wrote: "It seems to me that (type *)
NULL is still a perfectly good choice of value for such a parameter." is correct. I should have distinguished that in my original reply.
(
Log in to post comments)