(转)出现这样的警告 warning C4996: strcpy was declared deprecated
2011-07-19 10:05
573 查看
在使用VC 2005 的开发者会遇到这样的问题,在使用std命名空间库函数的时候,往往会出现类似于下面的警告: warning C4996: strcpy was declared deprecated
出现这样的警告,是因为VC2005中认为CRT中的一组函数如果使用不当,可能会产生诸如内存泄露、缓冲区溢出、非法访问等安全问题。这些函数如:strcpy、strcat等。
对于这些问题,VC2005建议使用这些函数的更高级的安全版本,即在这些函数名后面加了一个_s的函数。这些安全版本函数使用起来更有效,也便于识别,如:strcpy_s,calloc_s等。
当然,如果执意使用老版本、非安全版本函数,可以使用_CRT_SECURE_NO_DEPRECATE标记来忽略这些警告问题。办法是在编译选项 C/C++ | Preprocessor | Preprocessor Definitions中,增加_CRT_SECURE_NO_DEPRECATE标记即可。或在程序开头添加 #pragma warning(disable:4996) //全部关掉 #pragma warning(once:4996) //仅显示一个
出现这样的警告,是因为VC2005中认为CRT中的一组函数如果使用不当,可能会产生诸如内存泄露、缓冲区溢出、非法访问等安全问题。这些函数如:strcpy、strcat等。
对于这些问题,VC2005建议使用这些函数的更高级的安全版本,即在这些函数名后面加了一个_s的函数。这些安全版本函数使用起来更有效,也便于识别,如:strcpy_s,calloc_s等。
当然,如果执意使用老版本、非安全版本函数,可以使用_CRT_SECURE_NO_DEPRECATE标记来忽略这些警告问题。办法是在编译选项 C/C++ | Preprocessor | Preprocessor Definitions中,增加_CRT_SECURE_NO_DEPRECATE标记即可。或在程序开头添加 #pragma warning(disable:4996) //全部关掉 #pragma warning(once:4996) //仅显示一个
相关文章推荐
- VS2005 出现警告warning C4996: strcpy was declared deprecated 的解决办法
- VS2005 出现warning C4996: strcpy was declared deprecated
- VS2005 出现warning C4996: strcpy was declared deprecated
- warning C4996: 'strcpy' was declared deprecated
- warning C4996: '_snprintf' was declared deprecated 警告信息的消除方法
- visual studio 2005:warning C4996: strcpy was declared deprecated
- warning C4996: ''strcpy'' was declared deprecated
- VS2005编译VC6的工程,warning C4996: strcpy was declared deprecated
- warning C4996: strcpy was declared deprecated
- 《转》在VS2005下编译was declared deprecated警告
- warning C4996: 'sprintf' was declared deprecated see declaration of 'sprintf'
- 《warning C4996: 'sprintf' was declared deprecated see declaration of 'sprintf'》
- Visual C++ Tips: warning C4996: 'stricmp' was declared deprecated
- warning C4996: 'sprintf' was declared deprecated see declaration of 'sprintf'
- 在VS2005下编译was declared deprecated警告
- VC2005去掉烦人的warning C4996: '×××' was declared deprecated
- _tgetenv(),_tcscat() ,setmode(),_tsplitpath()等函数的 was declared deprecated 警告
- 'fopen' was declared deprecated
- 用g++编译最简单的C++程序hello.C出现可以用-Wno-deprecated屏蔽的警告,想问个究竟
- v4l2驱动摄像头 出现错误UINT64_C' was not declared in this scope 解决