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

后端 未结 6 598
既然无缘
既然无缘 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:46

    I have the same initial problem when compiling various software stacks with VC6 and Microsoft Platform SDK (in BaseTsd.h for example).

    What I (we) want to do is to control the compiler warning level for our code - we want to be able to play with the /W flag. In practice, as already pointed out, /W4 enables all generally useful warnings (and also some spurious...).

    As the problem comes from the MSFT header files, I modify in a clean way the Microsoft-supplied header files. There are not so many changes to implement.

    If compiler complains with warning C4305, in the source file I insert:

    #pragma warning( disable : 4305)
    

    before the offending line, followed by:

    #pragma warning( default : 4305)
    

    after the offending line. No side effect. Microsoft could have done it this way, probably.

提交回复
热议问题