5 ms·
I'm surprised it took them this long. I've used ``-Wall -Werror`` on all my code for decades. If you use it from the start it's easy to maintain and catches a
by jcoffland 9y ago
I'm surprised it took them this long. I've used ``-Wall -Werror`` on all my code for decades. If you use it from the start it's easy to maintain and catches a lot of potential bugs. There are the occasional false positives and warnings coming from 3rd party headers. For these I add warning specific suppressions.
- Someone 9y agoDid you build on many different platforms using multiple compilers with various degrees of standards support, just as Mozilla does? That makes it harder (for starters: how do you suppress warnings in a portable way?)
- frozenport 9y agoIt would be nifty to supress warnings on a per include directory level by passing flags directly to the compiler. This is how static analysis tools like PVS avoid flooding us with errors.
- Someone 9y agoThat’s what Mozilla does, too, reading the article. However, that’s not what the grandparent wrote: "For these I add warning specific suppressions”. I read that as disabling single warnings, not a compilation unit at a time. For example, in Visual Studio, you can do (https://msdn.microsoft.com/en-us/library/2c8f766e.aspx https://msdn.microsoft.com/en-us/library/2c8f766e.aspx): #pragma warning(push) #pragma warning(disable: 1234) ... #pragma warning(pop) Intel’s compiler is compatible with this (https://software.intel.com/en-us/cpp-compiler-18.0-developer-guide-and-reference-pragmas https://software.intel.com/en-us/cpp-compiler-18.0-developer...), but it would surprise me if it used the same warning numbers. GCC and clang, on the other hand, need (https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html#Diagnostic-Pragmas https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html#D..., https://clang.llvm.org/docs/UsersManual.html#controlling-diagnostics-via-pragmas https://clang.llvm.org/docs/UsersManual.html#controlling-dia...): #pragma GCC diagnostic push #pragma GCC diagnostic ignored “-W...” ... #pragma GCC diagnostic pop Because you ideally only want to target the exact place that triggers a warning, either is fairly wordy, and it gets worse if you want to cater for all three compilers. It also wouldn’t surprise me if Mozilla supported multiple versions of gcc (for instance because they want to build for an OS with long-term support, or for an obscure OS for which the latest gcc is not (yet) available). (_If_ you use C99, at least with gcc and clang, you can simplify that by using _Pragma, which has the big advantage that you can use it in preprocessor macros, so that you may be able to simplify what things look like in the source)
- frozenport 9y ago>> ideally only want to target the exact place that triggers a warning On the other hand, its typically some library that is messing up the static analysis tool. While the #pragama options are good for disabling warnings in typical projects, from personal experience they are broken in NVCC.
- jandrese 9y agoUsually what people do is they develop with -Wall -Werror but then turn off -Werror for the shipping version.
- santaclaus 9y ago> There are the occasional false positives and warnings coming from 3rd party headers. Can't you just -isystem those includes?
- MrMorden 9y agoAlso -Wextra, but I haven't tried the hyperpedantic options that need to be enabled individually.