3 ms·
That’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 tha
by Someone 9y ago
That’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.