Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Unfortunately, I don't think MSVC provides for a nice way to deal with this problem. I think you'll either need to continue explicitly turning warnings off/on when these headers are included (maybe using pragma macros to make it a bit easier <a href="https://stackoverflow.com/questions/3470003/wrapping-include-directives-with-other-preprocessor-commands/3470137#3470137">as Praetorian suggested</a>) or wrap the headers in your own headers that manage the warning level. The second option has the advantage of only needing to be done once. You can do this in a way that doesn't require you to modify each file that includes the original headers.</p> <p>Say that <code>HeaderGeneratingWarnings.h</code> is in the directory <code>ExtLibDir</code> which your project/makefile is configured to add to the compiler's include search path. One thing you might consider doing is add a 'parallel' directory, <code>ExtLibDirWrapper</code> and use <em>that</em> in the project/makefile configuration. Have it contain a set of headers that look something like:</p> <ul> <li><p><code>ExtLibDir\HeaderGeneratingWarnings.h</code>:</p> <pre><code>#ifndef HEADERGENERATINGWARNINGS_WRAPPER #define HEADERGENERATINGWARNINGS_WRAPPER #if defined(_MSC_VER) # pragma warning( push, 3 ) #endif #include "../ExtLibDir/SomeExternalHeader.h" #if defined(_MSC_VER) # pragma warning( pop ) #endif #endif /* HEADERGENERATINGWARNINGS_WRAPPER */ </code></pre></li> </ul> <p>An initial set of pain, but a pretty mechanical process - a script could probably be quickly knocked out to take care of the whole thing. Hopefully it would take care of the problem from that point onward.</p> <p>As an aside, GCC has a nice way to deal with this problem:</p> <ul> <li><a href="http://gcc.gnu.org/onlinedocs/cpp/System-Headers.html" rel="nofollow noreferrer">http://gcc.gnu.org/onlinedocs/cpp/System-Headers.html</a></li> </ul> <blockquote> <p>The header files declaring interfaces to the operating system and runtime libraries often cannot be written in strictly conforming C. Therefore, GCC gives code found in system headers special treatment. All warnings, other than those generated by `#warning' (see Diagnostics), are suppressed while GCC is processing a system header. Macros defined in a system header are immune to a few warnings wherever they are expanded. This immunity is granted on an ad-hoc basis, when we find that a warning generates lots of false positives because of code in macros defined in system headers.</p> <p>Normally, only the headers found in specific directories are considered system headers. These directories are determined when GCC is compiled. There are, however, two ways to make normal headers into system headers.</p> <p>The -isystem command line option adds its argument to the list of directories to search for headers, just like -I. Any headers found in that directory will be considered system headers.</p> <p>All directories named by -isystem are searched after all directories named by -I, no matter what their order was on the command line. If the same directory is named by both -I and -isystem, the -I option is ignored. GCC provides an informative message when this occurs if -v is used.</p> <p>There is also a directive, #pragma GCC system_header, which tells GCC to consider the rest of the current include file a system header, no matter where it was found. Code that comes before the <code>#pragma</code> in the file will not be affected. #pragma GCC system_header has no effect in the primary source file.</p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload