Re: Suppressing particular warnings for particular lines of code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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/

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux