Precedent for use of =

guy at sun.UUCP guy at sun.UUCP
Sun Jul 13 05:50:14 AEST 1986


> Hey, you can use assignment in C as if it were a statement only when you
> write YOUR C code, but in the example that you give its used in its full
> power as an operator, which can generate much more efficient code than
> the equivalent:
> 
> a=b
> if (b)

If your compiler can't generate equally efficient code for

	a = b;
	if (a != 0)

and

	if ((a = b) != 0)

on any machine other than an incredibly weird one, then your compiler needs
to be improved.
-- 
	Guy Harris
	{ihnp4, decvax, seismo, decwrl, ...}!sun!guy
	guy at sun.com (or guy at sun.arpa)



More information about the Comp.lang.c mailing list