C头文件行为不正常(C4996) [英] C Header file do not behave properly (C4996)

查看:105
本文介绍了C头文件行为不正常(C4996)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在VS2010中,当设置指令&_bsp; _CRT_SECURE_DEPRECATE_MEMORY时,它允许编译在使用memcpy()时显示警告并转而指向memcpy_s()。


In VS2017,无论代码使用memcpy还是memcpy_s,都会出现警告C4996。


删除该标志将删除警告,但这样做的目的就是警告开发人员使用安全功能。


为什么Microsoft改变了Header文件的行为?


他们是否计划修复它?


使用当开发人员使用memcpy()时,禁用C4996的pragma将失败警告的目的。


使用标志_CRT_SECURE_NO_WARNINGS没有警告或删除标志_CRT_SECURE_DEPRECATE_MEMORY将允许开发人员继续使用memcpy ()而不是安全功能。





Yigal Spinner

解决方案

你说"行为不当"。是什么让你觉得它不像微软想要的那样?


如果你更好地描述你需要做什么而不是抱怨它没有做什么,你可能会得到更好的帮助。 / p>


In VS2010, when setting the directive _CRT_SECURE_DEPRECATE_MEMORY, it allows the compile to show a warning when memcpy() was used and directed to memcpy_s() instead.

In VS2017, the warning C4996 appears regardless if the code uses memcpy or memcpy_s.

Removing the flag will remove the warning, but that defeat the purpose of warning the developer to use secure functions.

Why did Microsoft changed the behavior of the Header files?

Are they planing to fix it?

Using a pragma to disable C4996 will defeat the purpose of the warning when a developer using memcpy().

Using a flag _CRT_SECURE_NO_WARNINGS for no warning or removing the flag _CRT_SECURE_DEPRECATE_MEMORY will allow developers to continue using memcpy() and not the secure function.


Yigal Spinner

解决方案

You say "do not behave properly". What makes you think it is not behaving the way Microsoft intended?

Probably you will get better help if you describe better what you need to do instead of complaining about what it is not doing.


这篇关于C头文件行为不正常(C4996)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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