There is no way to disable `-Werror` for specific lines of code. I would use something like this: // I want errors about conversion here #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Werror=conversion" // I don't want errors about conversion here #pragma GCC diagnostic push // I want errors about conversion here
#pragma GCC diagnostic ignored "-Wconversion" is what you want. If you want it the warning still but not erroring out you use: #pragma GCC diagnostic warning "-Wconversion" This mentioned in the documentation too. https://gcc.gnu.org/onlinedocs/gcc-10.1.0/gcc/Diagnostic-Pragmas.html#Diagnostic-Pragmas
If I use #pragma GCC diagnostic ignored "-Wconversion" I will loose the warning. I still want the warning, but not the error. That's what I have right now as a workaround, but it's not what I want. ______ And this: #pragma GCC diagnostic warning "-Wconversion" hardcodes the warning. I want to be able to enable or disable "-Wconversion" in the command line. ______ There is no way to express that I want to enable or disable a warning/error at command line, but that some part of the code should never be an error.
Reopening because the original bug report was not clear.