How can I make this GCC warning an error?

I’m not sure what the correct warning is, but once you’ve found it, you can change its disposition with the following (using ‘format’ as the example):

#pragma GCC diagnostic error "-Wformat"

Or as strager points out:

gcc -Werror=format ...

I’ve checked the gcc source for this and this specific warning cannot be disabled via command line flags.

Leave a Comment