Do you have to cast void pointers when dereferencing them?

Wade Guthrie evil at arcturus.UUCP
Tue Dec 20 02:50:41 AEST 1988


In article <749 at auspex.UUCP>, guy at auspex.UUCP (Guy Harris) writes:

> Originally (well not ORIGINALLY. . .) I said:
>  >code must know the type of the lvalue to put the rvalue into the proper
>  >representation.  Is this not true?
> . . .Why is this any different from
> 	int foo; float bar; bar = foo;
> which also causes an implicit conversion from "int" to "float"?

The statement I made was regarding implicit conversion between pointer
types.  Well, as far as K&R goes, no implicit pointer type conversion
is made (they do describe how ints can be converted to float (actually
double, but I digress)).  This, I believe, is the root of some of the 
discussion lately that the following is non-portable:

	#define NULL (char *)0
	. . .
	int *foo;

	foo = NULL;

(note that different pointer types are on either side of the '=').


Wade Guthrie
Rockwell International
Anaheim, CA

(Rockwell doesn't necessarily believe / stand by what I'm saying; how could
they when *I* don't even know what I'm talking about???)



More information about the Comp.lang.c mailing list