error C4996: 'std::_Copy_impl'
以下代码段在VS2008编译可以通过,只是会提示不安全;
std::vector<unsigned char> fileData ="asdfsfsfsfsdf";//随便打的
//文件数据大小
int size = fileData.size();
//字节数组
char* data = new char[size + 1];
//把二进制数据复制到数组
std::copy(fileData.begin(), fileData.end(), data);
data[size] = 0;
但在VS2012就不能编译通过,VS2012进行了强制类型检查
1>C:\Program Files\Microsoft Visual Studio 11.0\VC\include\xutility(2176): 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> C:\Program Files\Microsoft Visual Studio 11.0\VC\include\xutility(2157) : 参见“std::_Copy_impl”的声明
1> HashParser.cpp(43): 参见对正在编译的函数 模板 实例化“_OutIt std::copy<std::_Vector_iterator<_Myvec>,char*>(_InIt,_InIt,_OutIt)”的引用
1> with
1> [
1> _OutIt=char *,
1> _Myvec=std::_Vector_val<std::_Simple_types<unsigned char>>,
1> _InIt=std::_Vector_iterator<std::_Vector_val<std::_Simple_types<unsigned char>>>
1> ]
解决:修改代码如下
std::vector<unsigned char> fileData = "sdfasdfasdfasf";
//文件数据大小
int size = fileData.size();
//字节数组
char* data = new char[size + 1];
//把二进制数据复制到数组
std::copy(fileData.begin(), fileData.end(), stdext::unchecked_array_iterator<char*>(data));
data[size] = 0;
参考:
http://choorucode.com/2010/08/30/visual-c-c4996-warning-on-copy-with-array-parameters/
error C4996: 'std::_Copy_impl'的更多相关文章
- VS2013编译程序出现error C4996: 'std::_Fill_n': Function call with parameters that may be unsafe
最近按照BiliBil网站Visual C++网络项目实战视频教程,使用VS2013编写一个基于MFC的对话框程序HttpSourceViewer,采用了WinHttp库.Boost xpressiv ...
- windows下编译caffe出现错误 C4996: 'std::_Copy_impl': Function call with parameters that may be unsafe?
解决方案来自http://blog.csdn.net/u012556077/article/details/50353818
- error C4996: Function call with parameters that may be unsafe – this call relies on the caller to ch
在加入QCustomplot时有如题的错误 1>c:\program files (x86)\microsoft visual studio11.0\vc\include\xutility(21 ...
- C++解决error C4996报错
今天用c++写了个数独程序,在编译过程中报了一个错误: 1>------ 已启动生成: 项目: sudoku, 配置: Debug Win32 ------1> main.cpp1> ...
- vs2012 error c4996: This function or variable may be unsafe
编译lua源码时,使用vs2012,遇到如下错误. 1>------ 已启动生成: 项目: 20130925, 配置: Debug Win32 ------ 1> stdafx.cpp ...
- 配置OpenCV产生flann\logger.h(66): error C4996: 'fopen': This function or variable may be unsafe问题[zz]
使用vs2012/2013配置opencv编译出现问题: 1>------ 已启动生成: 项目: Win32ForOpenCV245, 配置: Debug Win32 ------ 1> ...
- 1 error C4996: 'pcl::SAC_SAMPLE_SIZE':
使用PCL1.8 中使用粗配准拼接 错误 1 error C4996: 'pcl::SAC_SAMPLE_SIZE': This map is deprecated and is kept onl ...
- error C4996: 'fopen': This function or variable may be unsafe.
vs2013中错误提示信息: error C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s ...
- VS2013-解决error C4996: 'fopen'问题
VS2013中如何解决error C4996: 'fopen'问题 初次使用vs系列编辑器编写控制台应用程序时常出现如下错误: error C4996: 'fopen': This function ...
随机推荐
- java this 用法详解
一.JAVA提供了一个很好的东西,就是 this 对象,它可以在类里面来引用这个类的属性和方法. 代码例子: public class ThisDemo { String name="Mic ...
- Hive数子IP与字符串IP之间的转换
字符串IP:247.164.62.58 对应的 数字IP:4154736186 数子IP=>字符串IP select concat_ws('.',conv(substr(hex(41547 ...
- docker:nginx+confd动态生成配置
docker:nginx+confd动态生成配置 当我们项目越来越多时手动去服务器修改nginx配置是一件很麻烦而且可能出错的事情.我们可以通过nginx+confd+配置中心实现一套方案避免出错并减 ...
- Qt:QList、QStringList
QList 0.说明 QList<T> 一个QList是存储相同类型一组数据的列表. QStringList是从QList<String>继承而来,并添加了一些好用的方法,如j ...
- Leaflet:Marker、Popup类
Marker.Popup.Tooltip类都是继承自Layer类:Event与Layer Marker 1.用例 L.marker([41,123]).addTo(map); 2.实例化 L.mark ...
- Liunxa安装Nignx,Git
Linux安装Nignx 1.安装依赖 执行语句 yum install gcc patch libffi-devel python-devel zlib-devel bzip2-devel open ...
- Appium+ios环境搭建
appium 环境搭建 安装homebrew(Mac OSX上的软件包管理工具) $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubuse ...
- 如何使用 PuTTY 远程连接矩池云主机
PuTTY 是一款开源的连接软件,用来远程连接服务器,支持 SSH.Telnet.Serial 等协议. 矩池云的主机支持 SSH 登录,以下为使用 PuTTY 连接矩池云 GPU 的使用教程. 如您 ...
- Git更新本地仓库及冲突"Commit your changes or stash them before you can merge"解决
Git中从远程的分支获取最新的版本到本地有这样2个命令: 1. git fetch:相当于是从远程获取最新版本到本地,不会自动merge git fetch origin mastergit log ...
- 痞子衡嵌入式:恩智浦i.MX RTxxx系列MCU启动那些事(7)- 从SD/eMMC启动
大家好,我是痞子衡,是正经搞技术的痞子.今天痞子衡给大家介绍的是恩智浦i.MXRTxxx系列MCU的SD/eMMC卡启动. 关于 i.MXRT 启动设备,痞子衡之前写过很多篇文章,都是关于串并行 NO ...