casts to (void) [considered harmful]

Guy Harris guy at sun.uucp
Tue Aug 6 15:39:47 AEST 1985


> printf() is invariably used as a formatted-output statement,
> not as a value-returning function.

"invariably"?  Wrong.  The S5R2 "ls" uses the return value from "printf"
(which is the number of characters printed) to do its columnation.  I'm sure
there are other examples out there.

> DOWN WITH LINT SALAD!!!

It's unfortunate that so much effort has to be wasted on silencing harmless
"lint" complaints, but as anybody who's tried porting code to machines which
don't fit the VAX model of the world (32-bit "int"s, 32-bit pointers, signed
characters, little-endian byte order, etc.) will tell you, better to run
"lint" on the code and either spend the effort (void)ing everything or
filtering out the harmless complaints than to spend the effort on several
extra compile/run/debug/edit/compile... cycles fixing the problems caused by
code that assumes that model of the world.  (I've done it; I know whereof I
speak.)

	Guy Harris



More information about the Comp.lang.c mailing list