如何禁用 Visual Studio 2012 的警告? [英] How to disable Warnings of Visual Studio 2012?

查看:35
本文介绍了如何禁用 Visual Studio 2012 的警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个错误:

错误 C4996:'fopen':此函数或变量可能不安全.考虑使用 fopen_s 代替.要禁用弃用,请使用 _CRT_SECURE_NO_WARNINGS.有关详细信息,请参阅在线帮助.

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.

当我使用其他旧的 C 函数时会弹出类似的错误.我的问题是:有没有办法让这些错误像警告一样显示出来,而不实际阻止代码编译?

and similar errors pop up when I use other old C functions. My question is: Is there a way that these errors show up like Warnings, without actually preventing the code from compiling ?

推荐答案

你必须在你项目的预处理器设置中定义_CRT_SECURE_NO_WARNINGS,或者在开始处定义#define _CRT_SECURE_NO_WARNINGS使用 fopen() 的文件.或者直接使用 fopen_s() 代替.

You must define _CRT_SECURE_NO_WARNINGS in the preprocessor settings of your project, or #define _CRT_SECURE_NO_WARNINGS at the beginning of your file where you use fopen(). Or just use fopen_s() instead.

这篇关于如何禁用 Visual Studio 2012 的警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆