What's the best way to fix warnings from unused result

Eric S. Raymond esr at thyrsus.com
Sun Apr 7 15:11:47 UTC 2019


Hal Murray <hmurray at megapathdsl.net>:
> 
> esr at thyrsus.com said:
> > Probablty compiler version. As GCC has evolved it has gotten stricter about
> > this sort of thing. 
> 
> Fedora 29, no warnings:
> gcc (GCC) 8.3.1 20190223 (Red Hat 8.3.1-2)
> 
> Ubuntu 18.10, warnings
> gcc (Ubuntu 8.2.0-7ubuntu1) 8.2.0
> 
> Ubuntu 18.04.2 LTS, warnings
> gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0

Huh.  OK, it's weirder than I knew then. I don't know where the variation is coming
from. 

> > This is probably what you want:
> > ./include/ntp_stdlib.h:162:#define IGNORE(r) do{if(r){}}while(0)
> 
> Thanks.  Seems to be working.
> 
> While does that need the do/while around the if?  Doesn't the if alone do what 
> we want?

The do/while is a weird trick to make the macro statement-like so that you can
(and in fact must) follow it with a ;.
-- 
		<a href="http://www.catb.org/~esr/">Eric S. Raymond</a>




More information about the devel mailing list