This is the mail archive of the gcc-help@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: any way to disable a single *instance* of a GCC warning?


Interesting... I gave it a try. Even though the doc means results are
unpredictable, it seems to work, at least on a function by function
level. It does not work for a single line, though.

What I would like to do is:

	if(altdbg != NULL) fflush(altdbg);
#pragma GCC diagnostic ignored "-Wempty-body"
	pthread_cleanup_pop(1);
#pragma GCC diagnostic warning "-Wempty-body"
}

What seems to work is:

#pragma GCC diagnostic ignored "-Wempty-body"
func()
{
}
#pragma GCC diagnostic warning "-Wempty-body"

That is better, but still leaves a lot of code that no longer is
"protected" by the warning. Plus the doc says the way I am using it is
not supported ;) Any more clues?

Rainer


On Mon, Jun 23, 2008 at 10:54 AM, Rainer Gerhards <rgerhards@gmail.com> wrote:
> Hi Brian,
>
> thanks for your help. But I think these do not do what I actually
> need. As I understand them, they modify the compile option, but for
> the whole source file. I instead would like to modify the option for a
> single line (or maybe a couple of lines...) inside the same source
> file...
>
> Does that make sense?
>
> Rainer
>
> On Mon, Jun 23, 2008 at 10:50 AM, Brian Dessent <brian@dessent.net> wrote:
>> Rainer Gerhards wrote:
>>
>>> I wonder if there is any way to disable a warning for the next line. I
>>> have seen that some compilers do this via a #pragma, but I have not
>>> found any such pragma in GCC.
>>
>> gcc has supported this from 4.2 on:
>> <http://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html>
>>
>> Brian
>>
>


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