error C4996: 'fopen': This function or variable may be unsafe.

时间:2023-03-08 16:50:02
error C4996: 'fopen': This function or variable may be unsafe.

vs2013中错误提示信息:

error C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.

1>f:\program files (x86)\microsoft visual studio 12.0\vc\include\stdio.h(211) : 参见“fopen”的声明

原因:在demo中我使用了C语言库函数,具体参见:CRT函数的安全增强版本

解决办法:

更改预处理定义,屏蔽该错误:

设置项目->属性->配置属性->C/C++ -> 预处理器 -> 预处理器定义,添加:_CRT_SECURE_NO_WARNINGS。下图是修改后的

error C4996: 'fopen': This function or variable may be unsafe.

error C4996: 'fopen': This function or variable may be unsafe.