Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
478 views
in Technique[技术] by (71.8m points)

c++ - 默认情况下,在Visual Studio中从项目中删除安全警告(_CRT_SECURE_NO_WARNINGS)(Remove secure warnings (_CRT_SECURE_NO_WARNINGS) from projects by default in Visual Studio)

Is there a way to set by default for all projects removing the precompiler secure warnings that come up when using functions like scanf().

(是否有一种方法可以为所有项目默认设置,以消除使用scanf()之类的函数时出现的预编译器安全警告。)

I found that you can do it by adding a line in the project option or a #define _CRT_SECURE_NO_WARNINGS in the beginning of the code.

(我发现您可以通过在项目选项中添加一行或在代码开头添加#define _CRT_SECURE_NO_WARNINGS来实现。)

I find myself repeatedly creating new projects for solving programming contests and it is really annoying (and takes valuable time) to add:

(我发现自己反复创建新项目来解决编程竞赛,添加以下内容确实很烦人(并且花费了宝贵的时间):)

#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

In the beginning of the code, or to set it in the precompiler options every time I start a new project.

(在代码的开头,或者在每次启动新项目时在预编译器选项中进行设置。)

  ask by Juan Martinez translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Mark all the desired projects in solution explorer.

(在解决方案资源管理器中标记所有所需的项目。)

Press Alt-F7 or right click in solution explorer and select "Properties"

(按Alt-F7或在解决方案资源管理器中单击鼠标右键,然后选择“属性”)

Configurations:All Configurations

(配置:所有配置)

Click on the Preprocessor Definitions line to invoke its editor

(单击“预处理程序定义”行以调用其编辑器)

Choose Edit...

(选择编辑...)

Copy "_CRT_SECURE_NO_WARNINGS" into the Preprocessor Definitions white box on the top.

(将“ _CRT_SECURE_NO_WARNINGS”复制到顶部的“预处理程序定义”白框中。)

在此处输入图片说明


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...