Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84 SMI; site sun.uucp Path: utzoo!watmath!clyde!bonnie!akgua!sdcsvax!dcdwest!ittvax!decvax!decwrl!sun!tut From: tut@sun.uucp (Bill Tuthill) Newsgroups: net.lang.c Subject: When does void make code less readable? Message-ID: <1995@sun.uucp> Date: Fri, 15-Feb-85 14:50:07 EST Article-I.D.: sun.1995 Posted: Fri Feb 15 14:50:07 1985 Date-Received: Sun, 17-Feb-85 06:25:53 EST Distribution: net Organization: Sun Microsystems, Inc. Lines: 21 In general, void is A Good Thing. C routines that return a value are like Pascal functions, while C routines not returning values are like Pascal procedures, and should be declared as void to keep things clear. However, some system/library routines, such as close(), fclose(), and free() return values that programs don't usually care about. If the system is unable to close a file, you've got problems that a normal program can't deal with anyway. Nonetheless, lint encourages you to cast the return value of these routines to void. Now, I invite people to prove that the simple fclose(fp); is less portable than: (void)fclose(fp); I consider the first more portable-- many compilers on cheap micros don't know about void. The first version is also more readable-- anytime you throw extra keywords in, legibility decreases. Bill Tuthill