I'm trying to compile introduce the -Werror
flag in an existing codebase. One of the issues I'm encountering is that at some places #warning
is used to display informational messages. These should not be treated as an error.
One solution would be to use #pragma message
instead, but this does not seem to be supported by older versions of gcc. (Our build servers use gcc 4.1.2).
Can anyone help me fix this?
In gcc-4.6 and above, you can use -Wno-error=cpp
. In at least the clang released with Lion and later, you can use -Wno-error=#warnings
. But since your build servers use an ancient gcc, you're probably out of luck there.
In general, pass -fdiagnostics-show-option to have warnings show output like:
test.cc:1:2: warning: #warning hello [-Wcpp]
which tells you a warning flag that controls the warning. In gcc >=4.6 and clang, this is the default, so knowing to pass it may not be too useful anymore.
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