Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uflorida!haven!adm!cmcl2!stealth.acf.nyu.edu!brnstnd From: brnstnd@stealth.acf.nyu.edu Newsgroups: comp.lang.c Subject: Re: why "(void)printf(fmt);" besides lint(1)? Message-ID: <1494:May2720:24:0290@stealth.acf.nyu.edu> Date: 27 May 90 20:24:02 GMT References: <7486@ncar.ucar.edu> <1990May27.001120.13623@utzoo.uucp> Reply-To: brnstnd@stealth.acf.nyu.edu (Dan Bernstein) Distribution: usa Organization: IR Lines: 25 In article <1990May27.001120.13623@utzoo.uucp> henry@utzoo.uucp (Henry Spencer) writes: > In article <7486@ncar.ucar.edu> steve@groucho.ucar.edu (Steve Emmerson) writes: > >Aside from getting lint(1) to shut up, why else would one write > > (void)printf(fmt); > >rather than the simpler > > printf(fmt); > Personally, this is one of the few places where I just refuse to use the > cast. I consider it pointless clutter. If lint objects, tough. When I'm not checking a return value but know I should, I'll express that by writing ``if (...) ; /*XXX*/''. When I'm not checking a return value and don't see a need to, I'll express that by writing (void). When I think that a return value is totally pointless, I'll express that by defining a macro with the (void). Just as I find XXX useful to mark code needing more work, I find (void) useful to mark an ignored return value, no matter how unimportant. Later on I can use these hints to quickly search through my code for possible trouble spots. (Getting lint to shut up is useful in its own right: I regularly run my code through lint -haxc (and sometimes gcc -Wall -ansi -pedantic), and I want as few distractions as possible.) ---Dan