Disable / W4 warnings to enhance

How to disable all MSVC warnings that come from boost library?

I know that I can turn off certain warnings, where they occur, etc., but it clutters my code, and if I use boost macros, they don't seem to work. I would like to have an easy way to tell my compiler not to give me a raise warning. Is it possible?

On a secondary note, I'm a little surprised that the boost library does not turn off all of these warnings internally, so that we users can use it out of the box.

+4
source share
3 answers

They try very hard to avoid warnings, but some compilers warn that the formally correct code is a bit "suspicious". If you change the code to turn off the warning, another compiler can warn this code!

There is a warning policy for Boost code and various compilers https://svn.boost.org/trac/boost/wiki/Guidelines/WarningsGuidelines

They are also especially careful not to turn off warnings, because you may have some parts of your code where the warning is really correct. If Boost disables the warning, you cannot find errors in your code!

+2
source

You can turn off warnings for all projects by changing the properties of the default properties:

  • Open any project.
  • Click view-> property manager.
  • In (probably on the left bar), expand the project, then expand one of the profiles, then double-click on one of the categories that all your projects will use: Microsoft.Cpp.Win32.user, Application, or, possibly, Core Windows Libraries.
  • This leads to a Property Page, but for all the code you write or write. Install the appropriate pre-processor definitions and disable / wp 64 or whatever you need to do for a separate project.

Since it is probably undesirable to turn off these warnings for all projects, it seems that you can turn off warnings in visual_c.hpp, as described here: Raise warnings with VC ++ 9 , but then you will have to make changes every time you update their libraries.

+1
source

The first thing that comes to mind is to create a special header file in which you need to put all Boost #include s. These #include must be surrounded by #pragma blocks

 #pragma warning(push, 0) #include <boost/bimap.hpp> #include <boost/function.hpp> #pragma warning(pop) 

The disadvantage of this method: some compile-time inefficiencies

+1
source

Source: https://habr.com/ru/post/1344754/


All Articles