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 ...
随机推荐
- Hadoop分布式集群部署
环境准备 IP HOSTNAME SYSTEM 192.168.131.129 hadoop-master CentOS 7.6 192.168.131.135 hadoop-slave1 CentO ...
- [旧][Android] View 工作原理(二)
备注 原发表于2016.05.27,资料已过时,仅作备份,谨慎参考 前言 本文大量参照<Android 开发艺术探索>及参考资料的内容整合,主要帮助自己理清 View 的工作原理.深入学习 ...
- 【C#特性】 Attribute 特性
msdn:https://docs.microsoft.com/zh-cn/dotnet/csharp/programming-guide/concepts/attributes/creating-c ...
- 《Java编程思想》学习笔记(详细)
目录 01 对象导论 02 一切都是对象 03 操作符 04 控制执行流程 05 初始化与清理 06 访问权限控制 07 复用类(继承) 08 多态 09 接口 10 内部类 11 持有对象 12 通 ...
- 教程6--配置ssh
配置ssh 如果需要使用到远程仓库,那么就需要两个步骤: (1)配置创建SSH key(用于识别用户,免得每次输入账号密码) 在命令窗口输入ssh-keygen -t rsa -c "你的邮 ...
- strtok:This function or variable may be unsafe.
https://jingyan.baidu.com/article/49711c616b8a1ffa441b7cdc.html
- Python:lxml
学习自: python3解析库lxml - Py.qi - 博客园 lxml官方文档 lxml官方文档--lxml中的类.方法使用,如果需要查看某些方法的具体用法,就到这个网页下 python爬虫系列 ...
- broken pipe 报错分析和解决办法
参考资料: 1.博客1:https://blog.csdn.net/qq_37535749/article/details/113781338 2.博客2:https://blog.csdn.net/ ...
- 非关系型数据库redis
Redis初始 redis中不区分字母的大小写 查看端口 ss tnlp 安装 编译安装(需要先配置epel源) yum install -y redis 编译安装 wget https://down ...
- vue electron 运行时报错Cannot find module 'fs/promises'的解决方法
项目已经上线半年了,全省多地使用,突然出现的问题,最后发现是因为使用的 electron-updater 因为版本号没有锁定,突然之间就报了上面的错误,不管我怎么升级node都没用(哈哈,node本身 ...