Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1a 7/7/83; site rlgvax.UUCP Path: utzoo!linus!decvax!harpo!floyd!clyde!ihnp4!zehntel!hplabs!hao!seismo!rlgvax!guy From: guy@rlgvax.UUCP (Guy Harris) Newsgroups: net.lang.c Subject: Re: void avoidance Message-ID: <1274@rlgvax.UUCP> Date: Mon, 10-Oct-83 17:14:19 EDT Article-I.D.: rlgvax.1274 Posted: Mon Oct 10 17:14:19 1983 Date-Received: Thu, 13-Oct-83 00:02:07 EDT References: <5927@watmath.UUCP> Organization: CCI Office Systems Group, Reston, VA Lines: 54 oid) 1 but why should the compiler bother to detect a cast of a constant to a void and allow other expressions? One might as well be general, as there is no penalty... 2) (void) ++i; *CAN* be useful. Assume there is a macro like "putc" which is intended to look like a subroutine with side-effects and which also returns a value. Say you want to invoke the macro for its side effects and ignore its value. You can do that just by invoking it and not assigning the result to anything but "lint" will yell at you. The only way to shut it up is to cast its result to void. (This is not a hypothetical example; I have seen reasonable code which has run across this problem.) What harm does this facility do? I can't speak for Algol 68, which does have some sort of notion of void types, but it is very useful in C to throw away the result of a procedure called only for its side-effects. *I* suspect these rules were invented for just these purposes (there is explicit code in PCC/lint which understands casts to voids, so the ability to cast an expression to void did not "just 'come out in the wash'" there). Guy Harris {seismo,mcnc,we13,brl-bmd,allegra}!rlgvax!guy