[转] This function or variable may be unsafe
微软的警告,主要是那些都是C库的函数,很多函数内部是不进行参数检测的(包括越界类的),微软担心使用这些会造成内存异常,所以就改写了一下同样功能的函数,只不过进行了参数的检测,使用这些新的就可以了。不用特意记,每个函数在给出警告时都会告诉你相应的安全函数,注意一下警告信息就可以了,使用时再查看一下MSDN。库函数改写例子:
mkdir改写为
_mkdir
fopen”改写为
fopen_s
stricmp改写为
stricmp_s
解决:1>
根据下面的warning提示:参见“fopen”的声明
消息:“This function or variable may be
unsafe. Consider using fopen_s instead. To disable deprecation, use
_CRT_SECURE_NO_DEPRECATE. See online help for
details.”
所以可以将函数按warning提示的第二句使用fopen_s函数即可:
eg:FILE *pFile=fopen("1.txt", "w");
改为:
FILE* pFile;
fopen_s(&pFile, "1.txt", "w");
2>
还是根据warning提示的地三句话:use _CRT_SECURE_NO_DEPRECATE
项目|属性|配置属性|C/C++|命令行|附加选项,加入
【/D "_CRT_SECURE_NO_DEPRECATE"
】(注:加入中括号中完整的内容)
[转] This function or variable may be unsafe的更多相关文章
- 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> ...
- 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 ...
- Visual Studio 2015 编译错误【错误 C4996 'vsprintf': This function or variable may be unsafe. Consider using vsprintf_s instead. 】的解决方案
错误提示信息: 错误 C4996 'vsprintf': This function or variable may be unsafe. Consider using vsprintf_s inst ...
- 解决VS2013中“This function or variable may be unsafe”的问题
1.在VS2013中编译代码时出现如上错误信息,下面就介绍下如何解决This function or variable may be unsafe的问题. 2.用VS2013打开出现错误的代码文件 3 ...
- This function or variable may be unsafe. Consider using scanf_s instead.
去掉安全检查,开头加上即可: #define _CRT_SECURE_NO_WARNINGS 或者: 严重性代码 说明项目文件行禁止显示状态 错误C4996 'scanf': This functio ...
- 删除: warning C4996: 'sprintf': This function or variable may be unsafe. Consider 方法
可以使用的最简单的方法: 选项Project | Configuration Properties | C/C++ | Preprocessor | Preproc ...
- error C4996: 'strcpy': This function or variable may be unsafe.
vs2012用strcpy遇到的错误. 错误描述:error C4996: 'strcpy': This function or variable may be unsafe. Consider us ...
- VS 编译错误【error C4996: 'scanf': This function or variable may be unsafe. 】的解决方案
在VS中编译 C 语言项目,如果使用了 scanf 函数,编译时便会提示如下错误: error C4996: 'scanf': This function or variable may be uns ...
随机推荐
- JS创建类和对象
JavaScript 创建类/对象的几种方式 在JS中,创建对象(Create Object)并不完全是我们时常说的创建类对象,JS中的对象强调的是一种复合类型,JS中创建对象及对对象的访问是极其灵活 ...
- 后台字符串转化成json
function remotecontrol() { var progressbar = $("#progressbar"); $.ajax({ url: myurl, type: ...
- hdu 4712 Hamming Distance(随机函数暴力)
http://acm.hdu.edu.cn/showproblem.php?pid=4712 Hamming Distance Time Limit: 6000/3000 MS (Java/Other ...
- SpringMVC注解@RequestParam(转)
鸣谢:http://shawnccx.iteye.com/blog/730239 -------------------------------------------------- 在SpringM ...
- 重新学struct,边界对齐,声明……与Union的区别
在内存中,编译器按照成员列表顺序分别为每个结构体变量成员分配内存,当存储过程中需要满足边界对齐的要求时,编译器会在成员之间留下额外的内存空间. 如果想确认结构体占多少存储空间,则使用关键字sizeof ...
- pthread_create用法
linux下用C开发多线程程序,Linux系统下的多线程遵循POSIX线程接口,称为pthread. #include <pthread.h> int pthread_create(pth ...
- Socat
http://www.oschina.net/p/socat/ tcpick https://sourceforge.net/projects/tcpick/
- Why does yum return error: [Errno 256] No more mirrors to try ?
https://access.redhat.com/solutions/203603 ISSUE yum update fails with the error : [Errno 256] No mo ...
- linux 文件比对总结
1. 过滤a.log的重复数据 #统计 cat datatest.log|sort|uniq -d |wc -l #放入b.log cat datatest.log|sort|uniq -d > ...
- CentOS下安装XAMPP详细教程
现在php的集成运行环境越来越多,个人比较喜欢XAMPP,更新速度快,好用,安装便捷.windows下面的安装,就是下一步.下一步,没什么好说的,详细说一下linux下面的安装,这里以CentOS为例 ...