On Mon, 2005-12-05 at 21:25 -0500, Chris Shoemaker wrote: > If NULL is ((void*)0) you won't have any problem using NULL as a > sentinel, but using that definition of NULL opens up the possibility > of writing code that works with one implementation and not with > another. Specifically, you couldn't say "int *i = ((int *) NULL)" and > be sure it would mean the same thing for every compiler.
Yes you could. The whole point of the (void *) type is to represent a generic pointer that can be assigned to any other pointer type _without_ a cast. That's why it was invented. In C, the variable holds the type, not the value, so the (void *)0 automatically becomes an (int *) without a cast. A pointer to a char is the same size as a pointer to an int and is the same size as a pointer to void. The only difference is that when you increment a char*, it clicks by one byte, and when you increment an int*, it clicks by sizeof(int) bytes. Since int *i, above, is a pointer to int, it works as expected even though you initialize it with NULL. -- Karl Hegbloom <[EMAIL PROTECTED]> _______________________________________________ gnucash-devel mailing list gnucash-devel@gnucash.org https://lists.gnucash.org/mailman/listinfo/gnucash-devel