Path: utzoo!attcan!uunet!dptechno!dptechno.uucp From: dave@dptechno.uucp (Dave Lee) Newsgroups: comp.lang.c Subject: Why use (void) func() ? Message-ID: <586@dptechno.UUCP> Date: 21 Sep 90 21:15:19 GMT Sender: dave@dptechno.UUCP Organization: D.P. Technology Corp. Camarillo California Lines: 45 This is a bone I've been thinking about for some time. Given a simple function like : int func(){ ... } Whose return value I rarely care about --- say printf(). Why should I go to the extra trouble to write (void) printf("hello world\n"); Instead of printf("hello world\n"); IMHO, one of the great beauties of C is not distinguishing between procedure and function calls. The possible reasons I have deduced are: 1. shut up lint. 2. shut up the compiler To both 1 and 2 I reply: If I wanted to check the return value, I would have. This is not the sort of thing that results from a typo or unconcious omission. I never type func_call(); When I mean if( func_call() == whatever ) ...; I never "accidently" ommit a check for return value, though I may be lazy and decide to omit one. I believe this is a programming consideration, not a language one. Any comments on this? Of what real value is the extra "(void)", when IMHO omitting it is easier to read, shorter, and has identical meaning to the compiler. -- Dave Lee uunet!dptechno!dave