Jim Meyering <[EMAIL PROTECTED]> wrote: > "Manuel López-Ibáñez" <[EMAIL PROTECTED]> wrote: >> 2008/10/17 Bruno Haible <[EMAIL PROTECTED]>: >>> "#pragma GCC diagnostic" has a few limitations, which make it unusable to >>> resolve warnings like this one: >>> >>> Jim Meyering wrote in [1]: >>>> $ cat in.c >>>> int f (void) __attribute__ ((__warn_unused_result__)); >>>> void g (void) { (void) f (); } >>>> $ gcc -Werror -c in.c >>>> cc1: warnings being treated as errors >>>> in.c: In function 'g': >>>> in.c:2: error: ignoring return value of 'f', declared with attribute >>>> warn_unused_result > ... >> However, in this particular case, there is an easy workaround: >> >> int f (void) __attribute__ ((__warn_unused_result__)); >> void g (void) { int i; i = f (); } >> >> This silences the warning and makes it obvious that you are doing >> something fishy. > > Thanks, but I prefer to use the ignore_value function. > Adding a set-but-not-used variable might well provoke > a warning some day, if it doesn't already.
For those not following the original bug-gnulib thread, http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/15221 this is the function: static inline void ignore_value (int i __attribute__ ((__unused__))) { /* empty */ }