How can I work around warning C4505 in third party libraries?

前端 未结 2 719
长情又很酷
长情又很酷 2020-12-20 12:22

I\'ve got a project that uses Crypto++ for a few hashing functions. Recently, I decided to clean things up a bit and use warning level 4 on MSVC++.

Here\'s what my s

相关标签:
2条回答
  • 2020-12-20 12:57

    If you just need a few hashing functions, create a separate source file with 4505 disabled to include the crapto headers and write your own header file to define the function prototypes you use.

    0 讨论(0)
  • 2020-12-20 13:12

    The compiler can only determine unreferenced functions after it finished parsing the compiled source file. Move the corresponding #pragma disable out of the push/pop scope so it will still be in effect at the end of the file:

    #pragma warning(push)
    #pragma warning(disable: 4100) //Unreferenced formal parameter
    #pragma warning(disable: 4244) //Conversion, possible loss of data
    #pragma warning(disable: 4512) //Assignment operator could not be generated
    #pragma warning(disable: 4127) //Conditional expression is constant
    #define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1
    #include <cryptopp/md5.h>
    #include <cryptopp/sha.h>
    #pragma warning(pop)
    #pragma warning(disable: 4505) //Unreferenced local function has been removed
    
    0 讨论(0)
提交回复
热议问题