What's up with the thousands of warnings in standard headers in MSVC -Wall?

后端 未结 6 591
既然无缘
既然无缘 2020-11-27 16:22

Some people seem to advise you use -Wall, but when I did it on a small test project which just has a main.cpp with some includes, I get 5800 warnings most of them in standar

6条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-27 16:47

    I know that this is late in the game but I believe I have a way to use /Wall for your own files but not have to see the noise from the Microsoft or other "external" headers. This assumes you are using precompiled headers via stdafx.h.

    1. For the project, set the warning level to /Wall (maximum warnings)
    2. For the file stdafx.cpp, set the warning level to /W4 (lots of warnings enabled but MS headers pass silently)
    3. For the project, under Disable Specific Warnings, add 4652

    The first two seem obvious. But when stdafx.h is included in your own files, the warning levels do not match and warning C4652 is issued. Which defeats the whole exercise. But now that message is also suppressed.

    It is kinda tedious to do this for each new project but not as bad as lots of individual #pragma warning() suppressions.

提交回复
热议问题