pcc compiler error

M.J.Shannon mjs at eagle.UUCP
Mon Feb 11 02:04:56 AEST 1985


> The following code tests the contents of a pointer to a struct ...
> 
> struct xy  {
> 	int x;
> 	int y;
> } a;
> 
> main()
> {
> 	struct xy *p;
> 
> 	p = &a;
> 	if (*p) {
> 		/* compiler error: zzzcode- bad type */
> 	}
> }

This is not legitimate code (and the compiler should point this out).
The value of `*p' here is identical to the value of `a', a `struct xy'.
Thus, another equivalent way of saying what you did (equally wrong, at
least) is: `if (a != 0) { /* stuff */ }'.  It just isn't valid to
compare a structure value against an integer value.  Perhaps what you
meant to say is: `if (p != (struct xy *) 0) { /* stuff */ }'.
-- 
	Marty Shannon
UUCP:	ihnp4!eagle!mjs
Phone:	+1 201 522 6063



More information about the Comp.bugs.4bsd.ucb-fixes mailing list