* Suppressing particular warnings for particular lines of code
@ 2008-12-01 10:11 Yang Zhang
2008-12-04 5:53 ` Yang Zhang
0 siblings, 1 reply; 5+ messages in thread
From: Yang Zhang @ 2008-12-01 10:11 UTC (permalink / raw)
To: GCC-help
In Java, you can insert @SuppressWarnings(...) annotations before a line
to tell javac to suppress certain warnings for that line. Is there
anything similar for gcc?
--
Yang Zhang
http://www.mit.edu/~y_z/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Suppressing particular warnings for particular lines of code
2008-12-01 10:11 Suppressing particular warnings for particular lines of code Yang Zhang
@ 2008-12-04 5:53 ` Yang Zhang
2008-12-04 12:15 ` John (Eljay) Love-Jensen
0 siblings, 1 reply; 5+ messages in thread
From: Yang Zhang @ 2008-12-04 5:53 UTC (permalink / raw)
To: GCC-help
Yang Zhang wrote:
> In Java, you can insert @SuppressWarnings(...) annotations before a line
> to tell javac to suppress certain warnings for that line. Is there
> anything similar for gcc?
Anyone?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Suppressing particular warnings for particular lines of code
2008-12-04 5:53 ` Yang Zhang
@ 2008-12-04 12:15 ` John (Eljay) Love-Jensen
2008-12-04 19:47 ` Yang Zhang
0 siblings, 1 reply; 5+ messages in thread
From: John (Eljay) Love-Jensen @ 2008-12-04 12:15 UTC (permalink / raw)
To: Yang Zhang, GCC-help
Hi Yang,
>> In Java, you can insert @SuppressWarnings(...) annotations before a line
>> to tell javac to suppress certain warnings for that line. Is there
>> anything similar for gcc?
> Anyone?
For gcc, there are the compile line switches, such as -Wall, -Wextra, and
other -Wsomething which enable (or using -Wno-something, disable) the
warning.
There are no #pragma directives to disable warnings in-line with the code.
HTH,
--Eljay
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Suppressing particular warnings for particular lines of code
2008-12-04 12:15 ` John (Eljay) Love-Jensen
@ 2008-12-04 19:47 ` Yang Zhang
2008-12-04 20:15 ` Brian Dessent
0 siblings, 1 reply; 5+ messages in thread
From: Yang Zhang @ 2008-12-04 19:47 UTC (permalink / raw)
To: John (Eljay) Love-Jensen; +Cc: GCC-help
John (Eljay) Love-Jensen wrote:
> Hi Yang,
>
>>> In Java, you can insert @SuppressWarnings(...) annotations before a line
>>> to tell javac to suppress certain warnings for that line. Is there
>>> anything similar for gcc?
>
>> Anyone?
>
> For gcc, there are the compile line switches, such as -Wall, -Wextra, and
> other -Wsomething which enable (or using -Wno-something, disable) the
> warning.
Yeah, I know about these - they only apply to the entire source file,
whereas I'm interested in disabling warnings for particular lines.
>
> There are no #pragma directives to disable warnings in-line with the code.
I sense an itch here - write a grep-like tool that can filter out
warnings from gcc based on the presence of certain tokens in your source
file. For instance, inserting
// SuppressWarning(conversion)
into your source should cause the tool to filter out -Wconversion
warnings for the following line.
Have to think/experiment more about how to deal with multi-line
statements, though - not sure how gcc numbers lines in its warnings.
Also, this still won't work with -Werror (which is something I use), as
gcc itself will refuse to continue with the compilation.
--
Yang Zhang
http://www.mit.edu/~y_z/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Suppressing particular warnings for particular lines of code
2008-12-04 19:47 ` Yang Zhang
@ 2008-12-04 20:15 ` Brian Dessent
0 siblings, 0 replies; 5+ messages in thread
From: Brian Dessent @ 2008-12-04 20:15 UTC (permalink / raw)
To: Yang Zhang; +Cc: John (Eljay) Love-Jensen, GCC-help
Yang Zhang wrote:
> > There are no #pragma directives to disable warnings in-line with the code.
>
> I sense an itch here - write a grep-like tool that can filter out
> warnings from gcc based on the presence of certain tokens in your source
> file. For instance, inserting
From 4.2 and on gcc does support a form of #pragma control of
diagnostics, see
<http://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html>. However it
doesn't work the way you probably want, in that the setting is for the
whole file, not per-function. I think per-function support was in fact
part of the original plan but I don't know that anyone is currently
working on it.
Brian
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-12-04 20:15 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-01 10:11 Suppressing particular warnings for particular lines of code Yang Zhang
2008-12-04 5:53 ` Yang Zhang
2008-12-04 12:15 ` John (Eljay) Love-Jensen
2008-12-04 19:47 ` Yang Zhang
2008-12-04 20:15 ` Brian Dessent
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).