为什么启用SDL检查会将警告C4995转换为错误C4995? [英] Why does enabling SDL checks transform warning C4995 into error C4995?

查看:177
本文介绍了为什么启用SDL检查会将警告C4995转换为错误C4995?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天,在我重建C ++库及其单元测试程序之前,我决定在单元测试的项目设置中启用SDL检查。当它从Visual Studio 6升级到Visual Studio 2013时,在库项目中启用了SDL检查,并且其编译列表调出了十几个或SDL警告,主要是围绕 _tsprintf ,我可能永远无法修复,因为我不认为它们真的坏了。



我有很多其他项目,都启用了SDL检查,许多都有未解决的警告 _tprintf 和其他已弃用的CRT函数。到目前为止,这些都没有出现问题。



我最近发现并开始使用 #progrma弃用来标记我自己的旧功能,提醒我最终用他们的继承者替换它们。直到今天,这些已弃用的函数从未阻止我编译和链接库。我唯一可以看到的可能是这个项目与其他项目不同的是它的输出是一个字符模式程序,而其他的是动态链接库。



那里是关于Stack Overflow的讨论,它给了我一些我需要的提示要动起来然而,国际海事组织,提出的解决方案引出了一个问题;为什么 pragma警告的使用标记为错误,而其他每个实例都是警告



我尝试了什么:



我尝试过的,有效的是,正在消除SDL检查。

Today, before I rebuilt a C++ library and its unit test program, I decided to enable SDL checks in the project settings for the unit tests. SDL checks were enabled in the library project when it was upgraded from Visual Studio 6 to Visual Studio 2013, and its compilation listings call out a dozen or SDL warnings, mostly around _tsprintf, which I may never fix, because I don't see them as truly broken.

I have many other projects, all having SDL checks enabled, many with unresolved warnings around _tprintf and other deprecated CRT functions. To date, none of these has presented a problem.

I recently discovered and began using #progrma deprecate to flag certain of my own older functions, to remind me to eventually replace them with their successors. Until today, these deprecated functions have never prevented me compiling and linking a library. The only thing I can see that may differentiate this project from the others is that its output is a character mode program, while the others are dynamic-link libraries.

There is a discussion on Stack Overflow that gave me the hint that I needed to get moving. However, IMO, the proposed solution begs the question; why is this usage of pragma warning flagged as an error, while every other instance is a warning?

What I have tried:

What I tried, which worked, is eliminating the SDL checkes.

推荐答案

请参阅 / sdl (启用其他安全检查) [ ^ ]:

See /sdl (Enable Additional Security Checks)[^]:
Quote:

这些检查包括额外的安全相关警告错误

These checks include extra security-relevant warnings as errors




Quote:

/ sdl将这些警告设为错误:

...

C4995

/sdl enables these warnings as errors:
...
C4995



你得到了你所要求的。


You get what you asked for.


这篇关于为什么启用SDL检查会将警告C4995转换为错误C4995?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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