Disabling Warnings generated via _CRT_SECURE_NO_DEPRECATE

前端 未结 10 1624
说谎
说谎 2020-12-02 06:00

What is the best way to disable the warnings generated via _CRT_SECURE_NO_DEPRECATE that allows them to be reinstated with ease and will work across Visual Stud

10条回答
  •  被撕碎了的回忆
    2020-12-02 06:18

    Combination of @[macbirdie] and @[Adrian Borchardt] answer. Which proves to be very useful in production environment (not messing up previously existing warning, especially during cross-platform compile)

    #if (_MSC_VER >= 1400)         // Check MSC version
    #pragma warning(push)
    #pragma warning(disable: 4996) // Disable deprecation
    #endif 
    //...                          // ...
    strcat(base, cat);             // Sample depreciated code
    //...                          // ...
    #if (_MSC_VER >= 1400)         // Check MSC version
    #pragma warning(pop)           // Renable previous depreciations
    #endif
    

提交回复
热议问题