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++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- CString 到 char* 2021-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
