I have a few files where I'd like to be strict about warnings, and I use GCC to build my project.
I've tried #pragma GCC diagnostic error "-Wall"
as per 6.57.10 Diagnostic Pragmas, but it fails to account for some other enabled warning types:
foo.c:666:6: warning: passing argument 2 of 'bar' from incompatible pointer type [-Wincompatible-pointer-types]
Is there a way to enable -Werror for the file like it was supplied from the command line (or, at least, for the implicitly enabled set of warnings), so any warning would trigger an error?
For this case, you can use
#pragma GCC diagnostic error "-Wincompatible-pointer-types"
as for example in
#pragma GCC diagnostic error "-Wincompatible-pointer-types"
void foo(int * a)
{
}
void bar() {
foo("foo");
}
Using -Wall with this pragma is not supported. Only diagnostic options are supported, that are shown with -fdiagnostics-show-option
(which is the default today anyway), as in your example warning above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With