Why does Visual Studio 2013 error on C4996?(为什么 Visual Studio 2013 在 C4996 上出错?)
问题描述
在以前版本的 Visual Studio 中,使用 _sleep 或 strncpy 等函数只会输出警告.最新版本,突然报错:
In previous versions of Visual Studio using functions like _sleep or strncpy just outputs a warning. In the latest version, it's suddenly an error:
错误 C4996:'_sleep':此函数或变量已被取代通过更新的库或操作系统功能.考虑使用睡吧.有关详细信息,请参阅在线帮助.
error C4996: '_sleep': This function or variable has been superseded by newer library or operating system functionality. Consider using Sleep instead. See online help for details.
我知道我可以通过在代码的开头添加 #pragma warning(disable: 4996)
来禁用它,但是非常烦人的是 VS 试图强迫我使用其他功能.有什么办法可以禁用这种行为吗?
I know I can disable it by adding #pragma warning(disable: 4996)
in the beginning of the code, but it's extremely annoying that VS is trying to force me to use other functions. Is there any way to disable this behavior?
在您询问之前,将警告视为错误"已禁用,即使我关闭所有警告,它也会出错!
Before you ask, "Treat Warnings As Errors" is disabled, and it errors even if I turn off all warnings!
推荐答案
显然新项目现在默认启用SDK 检查",将这些警告视为错误.要禁用它,请转到项目属性 -> 配置属性 -> C/C++ -> 常规 -> SDL 检查 -> 否.
Apparently new projects enable "SDK check" by default now, which treats these warnings as errors. To disable it, go to project properties -> Configuration Properties -> C/C++ -> General -> SDL checks -> No.
这篇关于为什么 Visual Studio 2013 在 C4996 上出错?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为什么 Visual Studio 2013 在 C4996 上出错?


- 近似搜索的工作原理 2021-01-01
- 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01
- 如何对自定义类的向量使用std::find()? 2022-11-07
- 从python回调到c++的选项 2022-11-16
- 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01
- 静态初始化顺序失败 2022-01-01
- 使用/clr 时出现 LNK2022 错误 2022-01-01
- Stroustrup 的 Simple_window.h 2022-01-01
- STL 中有 dereference_iterator 吗? 2022-01-01
- C++ 协变模板 2021-01-01