Visual Studio 2015 不会抑制错误 C4996 [英] Visual Studio 2015 won't suppress error C4996
问题描述
Visual Studio 2015 Community Edition 在调试中编译时出现以下错误,但在发布中编译时没有:
Visual Studio 2015 Community Edition gives the following error when compiling in debug, but not when compiling in release:
std::copy::_Unchecked_iterators::_Deprecate': Call to 'std::copy' with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators'
<小时>
我能够将这个错误的根源追溯到 这个第三方的第 214 和 242 行库 我用来写位图图像.我不完全理解这些部分发生了什么,所以我宁愿不要乱搞.
I was able to trace back the source of this error to lines 214 and 242 of this third party library I'm using to write bitmap images. I don't fully understand what is going on in these parts, so I'd rather not mess with it.
我正在尝试禁用此错误,但 Visual Studio 不允许.我尝试了以下建议的解决方案 在文档中,在StackOverflow 或其他地方:
I'm trying to disable this error, but Visual Studio won't let me. I've tried the following solutions that were suggested in the documentation, on StackOverflow, or elsewhere:
- 将
4996
添加到项目设置">配置属性">C/C++">高级"中的禁用特定警告"字段. - 将
/wd4996
添加到项目设置">配置属性">调试"中的命令参数"字段. - 在有问题的文件顶部和/或有问题的函数上方添加
#pragma warning (disable : 4996)
. - 将
_SCL_SECURE_NO_WARNINGS
、_SCL_NONSTDC_NO_WARNINGS
、_SCL_OBSOLETE_NO_WARNINGS
、_SCL_SECURE_NO_WARNINGS_GLOBAL
及其组合定义到预处理"字段中在项目设置 > 配置属性 > C/C++ > 预处理器中. - 使用
#define
指令将先前解决方案中的定义添加到违规文件的顶部. - 将先前解决方案中的定义添加到命令参数"字段中,但以
/D
或-D
为前缀.
- Add
4996
to the "Disable Specific Warnings" field in Project Settings > Configuration Properties > C/C++ > Advanced. - Add
/wd4996
to the "Command Arguments" field in Project Settings > Configuration Properties > Debugging. - Add
#pragma warning (disable : 4996)
at the top of the offending file, and/or above the offending function. - Add
_SCL_SECURE_NO_WARNINGS
,_SCL_NONSTDC_NO_WARNINGS
,_SCL_OBSOLETE_NO_WARNINGS
,_SCL_SECURE_NO_WARNINGS_GLOBAL
, and combinations thereof to the "Preprocessor Definitions" field in Project Settings > Configuration Properties > C/C++ > Preprocessor. - Add the definitions from the previous solution with a
#define
directive to the top of the offending file. - Add the definitions from the previous solution but prefixed with
/D
or with-D
to the "Command Arguments" field.
但这些都不能解决我的问题.
But none of this fixes the issue for me.
Visual Studio 坚持显示此错误的可能原因是什么?
What could possibly be the reason for Visual Studio to keep insisting on displaying this error?
推荐答案
这篇关于Visual Studio 2015 不会抑制错误 C4996的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!