如何使用_CRT_SECURE_NO_WARNINGS

在我的简单 MFC 窗口应用程序中,我有几行代码从向导生成的编译错误:

I have compile error in my simple MFC window application generated from wizard with several lines of code:

错误 C4996:'strncpy':此函数或变量可能不安全.考虑使用 strncpy_s 代替.要禁用弃用,请使用 _CRT_SECURE_NO_WARNINGS.有关详细信息,请参阅在线帮助.

error C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.

我设置Configuration Properties>>C/C++>>Preporocessor>>Preprocessor Definitions>>_CRT_NONSTDC_NO_WARNINGS

但这无济于事.我有另一个非常接近的项目,它只在这个地方生成警告,并且没有 _CRT_NONSTDC_NO_WARNINGS 定义.

But this does't helped. I have another very close project that generates only warning in this place and it has no _CRT_NONSTDC_NO_WARNINGS definition.

项目之间的唯一区别是向导中有几个不同的选项.

Only difference between projects is several different options in wizard.

为什么 _CRT_NONSTDC_NO_WARNINGS 在第一个项目中没有帮助,为什么第二个项目在没有这个定义的情况下编译没有问题?

Why _CRT_NONSTDC_NO_WARNINGS does not helps in first project and why second project compiles without problems without this definition?

推荐答案

添加者

配置属性>>C/C++>>预处理器>>预处理器定义>> _CRT_SECURE_NO_WARNINGS

Configuration Properties>>C/C++>>Preporocessor>>Preprocessor Definitions>> _CRT_SECURE_NO_WARNINGS

相关文章