2
votes

I'm working on a C++ project that uses OpenCV and Boost. Unfortunately when compiling, my compiler gives me hundreds of warnings from the include files of those libraries. Even with an empty main function and no other code I still get these warnings from the include statements. I've heard this is a problem with other 3rd party libraries like Qt. All great libraries. How can I suppress all 3rd party warnings in MSVC.

I know about these solutions:

I've spend hours on these last 2 solutions but without any success. The "broken warnings theory" blog doesn't explain how to apply its solution very well anyway.

I'm using:

  • Visual Studio 2015 and 2019.
  • Boost 1.72
  • OpenCV4

I really appreciate anyone willing to help resolve this issue with me. It would be nice to know who has even solved this issue. So many companies use these libraries, some probably with MSVC. There's no way they just keep with the warnings there and forget about them. I'm at the point where I will pay money to get this resolved. Getting this to work may be the deciding factor between reusing 3rd party libraries and rewriting code myself.

1
Even with an empty main function and no other code I still get these warnings from the include statements. -- Which includes give you warnings with an empty main? I can't quite believe that. - DevSolar
Which MSVC warning level are you targeting? - Bathsheba
Where did you find that pragma push only works for your own headers? - Botje
There's no way they just keep with the warnings there and forget about them. I'm at the point where I will pay money to get this resolved. -- You'd have to start with giving a reproducible example of what warnings you're talking about... - DevSolar
Here's a simple example of my code: #include <boost/asio.hpp> int main() { boost::asio::io_context context; return 0; } - IronMan

1 Answers

1
votes

All this is from this blog post: https://devblogs.microsoft.com/cppblog/broken-warnings-theory/. The general tone of the introduction of the article speaks volumes about why this option wasn't there to begin with (and none of it makes much sense to me).

Basically this says you can use /external:I as a synonym to -isystem. You will probably need /external:templates- as well, due to the way MSVC handles warnings from templates.

Unfortunately, I cannot find any reference to any of this in the MSVC commandline documentation, nor the release notes related to the mentioned VS2017 15.6, so your mileage may vary. There is though, a CMake issue requesting support for this feature behind their SYSTEM modifier.