Disabling Warnings generated via _CRT_SECURE_NO_DEPRECATE

前端 未结 10 1625
说谎
说谎 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:22

    If you don't want to pollute your source code (after all this warning presents only with Microsoft compiler), add _CRT_SECURE_NO_WARNINGS symbol to your project settings via "Project"->"Properties"->"Configuration properties"->"C/C++"->"Preprocessor"->"Preprocessor definitions".

    Also you can define it just before you include a header file which generates this warning. You should add something like this

    #ifdef _MSC_VER
    #define _CRT_SECURE_NO_WARNINGS
    #endif
    

    And just a small remark, make sure you understand what this warning stands for, and maybe, if you don't intend to use other compilers than MSVC, consider using safer version of functions i.e. strcpy_s instead of strcpy.

提交回复
热议问题