如何使用_CRT_SECURE_NO_WARNINGS

2023-06-03C/C++开发问题
7

本文介绍了如何使用_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

这篇关于如何使用_CRT_SECURE_NO_WARNINGS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

无法访问 C++ std::set 中对象的非常量成员函数
Unable to access non-const member functions of objects in C++ std::set(无法访问 C++ std::set 中对象的非常量成员函数)...
2024-08-14 C/C++开发问题
17

从 lambda 构造 std::function 参数
Constructing std::function argument from lambda(从 lambda 构造 std::function 参数)...
2024-08-14 C/C++开发问题
25

STL BigInt 类实现
STL BigInt class implementation(STL BigInt 类实现)...
2024-08-14 C/C++开发问题
3

使用 std::atomic 和 std::condition_variable 同步不可靠
Sync is unreliable using std::atomic and std::condition_variable(使用 std::atomic 和 std::condition_variable 同步不可靠)...
2024-08-14 C/C++开发问题
17

在 STL 中将列表元素移动到末尾
Move list element to the end in STL(在 STL 中将列表元素移动到末尾)...
2024-08-14 C/C++开发问题
9

为什么禁止对存储在 STL 容器中的类重载 operator&()?
Why is overloading operatoramp;() prohibited for classes stored in STL containers?(为什么禁止对存储在 STL 容器中的类重载 operatoramp;()?)...
2024-08-14 C/C++开发问题
6