Re: How do I add a warning like Wformat to gcc?

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

 



On Mon, Jul 31, 2023 at 06:19:15PM +0800, Julian Waters via Gcc-help wrote:
> Quick question, how does one define a new warning that accepts different
> levels like Wformat? Right now I have the following:

See c-family/c.opt, the block that starts
Wformat=

Here the whole thing, it's short anyway:
Wformat=
C ObjC C++ ObjC++ Joined RejectNegative UInteger Var(warn_format) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall, 1, 0) IntegerRange(0, 2)
Warn about printf/scanf/strftime/strfmon format string anomalies.

> I don't quite understand what the syntax or each setting following the
> warning definition means,

https://gcc.gnu.org/onlinedocs/gccint/Options.html

> nor how to check for warning levels in the
> corresponding code for the warning

The "warn_format" variable is set to 0..2, and you can check that
however you want.

> (Eg what does Joined do?), so some
> pointers would be appreciated for that

"Joined" means you write the argument as part of the option, while
"Separate" means it is a separate arg.  As in "-Wformat=2" is Joined,
while "-Wformat 2" would be separate.


Segher



[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