VS2005 出现warning C4996: strcpy was declared deprecated
2008-04-14 14:54
477 查看
在使用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编译VC6的工程,warning C4996: strcpy was declared deprecated
- (转)出现这样的警告 warning C4996: strcpy was declared deprecated
- warning C4996: 'strcpy' was declared deprecated
- warning C4996: ''strcpy'' was declared deprecated
- warning C4996: strcpy was declared deprecated
- visual studio 2005:warning C4996: strcpy was declared deprecated
- warning C4996: 'sprintf' was declared deprecated see declaration of 'sprintf'
- 《转》在VS2005下编译was declared deprecated警告
- warning C4996: 'sprintf' was declared deprecated see declaration of 'sprintf'
- 《warning C4996: 'sprintf' was declared deprecated see declaration of 'sprintf'》
- 在VS2005下编译was declared deprecated警告
- warning C4996: '_snprintf' was declared deprecated 警告信息的消除方法
- VC2005去掉烦人的warning C4996: '×××' was declared deprecated
- Visual C++ Tips: warning C4996: 'stricmp' was declared deprecated
- Error 3 error C4996: 'cv::flann::Index_<T>': was declared deprecated c:\open
- Arduino- 编译引用 IRremote 出现 error: ‘TKD2′ was not declared in this scope
- 用g++ 编译 ffmpeg 编译出现 error: 'UINT64_C' was not declared in this scope 或 missing -D__STDC_CONSTANT_MACROS
- 'function': was declared deprecated