- 📚 相关推荐文章
- sscanf: This function or variable may be unsafe.Consider using scanf 推荐
- warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you me 推荐
- function()默认参数中ReferenceError Cannot access ‘a‘ before initialization的解决方法 推荐
- CSS 函数 Function 推荐
- 分析Not enough variable values available to expand ‘xxx‘ 推荐

C4996 ‘localtime‘: This function or variable may be unsafe. Consider using localtime
Question: C++ 使用localtime:
time_t timep; time(&timep); char tmp[256]; strftime(tmp, sizeof(tmp), "%Y-%m-%d %H:%M:%S", localtime(&timep)); Console::WriteLine(tmp);提示: 警告 14 warning C4996: 'localtime': This function or variable may be unsafe. Consider using localtime_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
Answer:
1, 在项目设置的C/C++选项中,把检查64位移植性去掉。 2, 方案a:使用_localtime_s, _localtime32_s, _localtime64_s这3个函数代替localtime 方案b:去掉C4996警告,比如按照提示所说 #define _CRT_SECURE_NO_WARNINGS 1 或者直接#pragma warning( disable : 4996 )
👁️ 阅读量:0
© 版权声明:本文《C4996 ‘localtime‘: This function or variable may be unsafe. Consider using localtime》内容均为本站精心整理或网友自愿分享,如需转载请注明原文出处:https://www.zastudy.cn/wen/1686551993a289789.html。