[PATCH] Fixes sentinel warnings on GCC4

Karl Hegbloom hegbloom at pdx.edu
Tue Dec 6 11:57:45 EST 2005


On Tue, 2005-12-06 at 08:43 -0800, Karl Hegbloom wrote:
> 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.

To disambiguate... here I mean that the type information is held by the
internal compiler struct that represents the variable, not by a struct
that represents the variable's value.  For contrast, in Lisp, the value
has a type, but the variable location can hold an object of any type.

-- 
Karl Hegbloom <hegbloom at pdx.edu>



More information about the gnucash-devel mailing list