This function or variable may be unsafe
来源:互联网 发布:广西网络电视台直播 编辑:程序博客网 时间:2024/05/16 23:35
1>------ Build started: Project: wintest, Configuration: Debug Win32 ------
1> Source.cpp
1>d:\vs2010\onlyforfun\onlyforfun\wintest\source.cpp(11): error C4996: 'sscanf': This function or variable may be unsafe. Consider using sscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> d:\vs2012\vc\include\stdio.h(311) : see declaration of 'sscanf'
1> Source.cpp
1>d:\vs2010\onlyforfun\onlyforfun\wintest\source.cpp(11): error C4996: 'sscanf': This function or variable may be unsafe. Consider using sscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> d:\vs2012\vc\include\stdio.h(311) : see declaration of 'sscanf'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
在VS2012中编写c++代码时,调用某个c语言库函数,如上提示,
原因解释
这种微软的警告,主要因为那些C库的函数,很多函数内部是不进行参数检测的(包括越界类的),微软担心使用这些会造成内存异常,所以就改写了同样功能的函数,改写了的函数进行了参数的检测,使用这些新的函数会更安全和便捷。关于这些改写的函数你不用专门去记忆,因为编译器对于每个函数在给出警告时,都会告诉你相应的安全函数,查看警告信息就可以获知,在使用时也再查看一下MSDN详细了解。
解决办法:
1、在所有引用头文件之上#define _CRT_SECURE_NO_WARNINGS
2、#pragma warning(disable : 4996)
3、PROJECT->Properties->c/c++->Command Line->Additional Options
加入/D "_CRT_SECURE_NO_DEPRECATE"
- 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
- 《Expert Android》关键点摘录之一:Exploring Custom Views
- Andriod基本技巧——数据转化
- 走进小作坊(一)--------谈谈学习方法
- 解决 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) 问题
- vc 网络编程(socket)
- This function or variable may be unsafe
- SSH框架org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in
- buffer.cpp
- 如何向数据库添加时同时返回ID
- adb device找不到设备
- VC++网络编程基础
- 走进小作坊(二)----《疯子》与学习心得
- c 语言小程序
- MIPS汇编语言参考