This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: pragma GCC diagnostic


"Manuel LÃpez-IbÃÃez" <lopezibanez@gmail.com> wrote:
> 2008/10/17 Bruno Haible <bruno@clisp.org>:
>> "#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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]