简体   繁体   中英

How to disable deprecation warnings for C/C++ compiler globally in Visual Studio 2019?

I want to have deprecation warnings(C4996, the ones caused by calling functions like strcpy) disabled by default in all C/C++ projects in Visual Studio 2019.

There are several ways on the internet on how to do it, but they are all on a per-project basis, the most straightforward way is to add _CRT_SECURE_NO_WARNINGS to the preprocessor definitions. But I want to achieve this effect automatically, without having to fiddle with the project setting each time I make a new project.

I know there must be a way. I don't care how "hacky" the method is. Using the safe variants of the functions isn't an option for me.

You can create custom project templates in Visual Studio, so you should be able to create one of these with whatever #defines you want pre-configured in the properties page.

MS documentation is here and a guy called Srinivasa Rao Dhulipalla has blogged about it here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM