why "(void)printf(fmt);" besides lint(1)?
brnstnd at stealth.acf.nyu.edu
brnstnd at stealth.acf.nyu.edu
Mon May 28 06:24:02 AEST 1990
In article <1990May27.001120.13623 at utzoo.uucp> henry at utzoo.uucp (Henry Spencer) writes:
> In article <7486 at ncar.ucar.edu> steve at 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
More information about the Comp.lang.c
mailing list