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 上出错?


基础教程推荐
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 常量变量在标题中不起作用 2021-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 这个宏可以转换成函数吗? 2022-01-01
- 我有静态或动态 boost 库吗? 2021-01-01