为什么 Visual Studio 2013 在 C4996 上出错? [英] Why does Visual Studio 2013 error on C4996?

查看:21
本文介绍了为什么 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 上出错?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆