This function or variable may be unsafe
来源:互联网 发布:网络投标书名字 编辑:程序博客网 时间:2024/06/04 08:37
微软的警告,主要是那些都是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" 】(注:加入中括号中完整的内容)
本文地址:http://blog.sina.com.cn/s/blog_63a9d0880100vdor.html
- This function or variable may be unsafe
- This function or variable may be unsafe
- This function or variable may be unsafe
- This function or variable may be unsafe
- This function or variable may be unsafe
- This function or variable may be unsafe
- This function or variable may be unsafe
- This function or variable may be unsafe
- This function or variable may be unsafe
- [Error]'fopen'This function or variable may be unsafe
- [转]This function or variable may be unsafe 解决办法
- warning C4996: 'strcpy': This function or variable may be unsafe.
- error C4996: 'sprintf': This function or variable may be unsafe
- error C4996: 'sprintf': This function or variable may be unsafe.
- vs2013 error c4996: This function or variable may be unsafe
- vs2012 error c4996: This function or variable may be unsafe
- 'strcpy': This function or variable may be unsafe
- 解决VS2012中This function or variable may be unsafe
- IOS-线程操作之NSThread/NSOperation/GCD
- Java:String 转 long
- mac系统下配置Eclipse Java/C++ 开发环境
- codeforces content#260 D A Lot of Games
- 43亿整数中查找至少出现2次整数
- This function or variable may be unsafe
- Codeforces Round #260 (Div. 2) (DP没学好。。)
- C语言符号优先级
- Eclipse常用快捷键使用
- ListView嵌套GridView使用详解及注意事项
- [编程之美] PSet2.18 数组分割
- IOS 字符串中去除特殊符号
- php常见问题解决
- install qt on ubuntu 14.04