Modern compilers have ways to suppress warnings from system headers.
---
For (modern) g++ that's the default, and you have to explicitly enable
warnings from system headers if you're interested in them:
<url:
https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wsystem-headers>
«
-Wsystem-headers
Print warning messages for constructs found in system header files.
Warnings from system headers are normally suppressed, on the assumption
that they usually do not indicate real problems and would only make the
compiler output harder to read. Using this command-line option tells GCC
to emit warnings from system headers as if they occurred in user code.
However, note that using -Wall in conjunction with this option does not
warn about unknown pragmas in system headers—for that, -Wunknown-pragmas
must also be used.
»
To designate a directory as containing system headers,
<url:
https://gcc.gnu.org/onlinedocs/gcc/Directory-Options.html#Directory-Options>
«
The -isystem and -idirafter options also mark the directory as a system
directory, so that it gets the same special treatment that is applied to
the standard system directories.
»
---
Visual C++ only recently gained the ability to let the user
differentiate between system headers and headers in general. As of
Visual C++ 2019 it's still an experimental feature. I.e., the details
may possibly still change.
In typical Microsoft fashion it's done via an excessively verbose COBOL
like syntax with no reasonable defaults, no doubt either designed to
look impressive to some non-technical MS manager, or designed by such.
[In the Windows Cmd interpreter:]
«
> cl /? 2>&1 | find /i "external"
/FC use full pathnames in diagnostics /H<num> max external name length
/external:I <path> - location of external headers
/external:env:<var> - environment variable with locations of
external headers
/external:anglebrackets - treat all headers included via <> as external
/external:W<n> - warning level for external headers
/external:templates[-] - evaluate warning level across template
instantiation chain
»
Some explanation and background: <url:
https://devblogs.microsoft.com/cppblog/broken-warnings-theory/>.
> There are policies and there's taking policies too far.
Yes, agreed. :)
- Alf