C++解决error C4996报错

今天用c++写了个数独程序,在编译过程当中报了一个错误:c++

1>------ 已启动生成: 项目: sudoku, 配置: Debug Win32 ------
1> main.cpp
1> function.cpp
1>e:\program files (x86)\microsoft visual studio 12.0\vc\include\xutility(2132): error C4996: 'std::_Copy_impl': Function call 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'
1> e:\program files (x86)\microsoft visual studio 12.0\vc\include\xutility(2113) : 参见“std::_Copy_impl”的声明
1> d:\coding_file\cpp\sudoku\sudoku\function.cpp(73): 参见对正在编译的函数 模板 实例化“_OutIt std::copy<_Ty*,_Ty*>(_InIt,_InIt,_OutIt)”的引用
1> with
1> [
1> _OutIt=int *
1> , _Ty=int
1> , _InIt=int *
1> ]
1> 正在生成代码...安全

这是关于安全性的警告,错误代码为4996,问题出如今标准库函数copy()的使用上,有两种方法能够忽略:函数

1.在出现报错的cpp文件的文件头加上#pragma warning(disable : 4996) 注:该语句只对当前文件生效,并不是对整个工程this

2.打开当前项目的属性页,选择 配置属性->C/C++->预处理器,在预处理器定义中加上_SCL_SECURE_NO_WARNINGS,多个属性间以分号分隔 注:该项设置对整个工程生效spa

相关文章
相关标签/搜索