Why does Visual Studio 2013 error on C4996?
Solution 1
Apparently new projects enable "SDK check" by default now, which treats these warnings as errors. To disable it, go to project properties -> Configuration Properties -> C/C++ -> General -> SDL checks -> No.
Solution 2
enter at the beginning of the program:
#pragma warning(disable : 4996)
and that's it.
Solution 3
You can also disable specific warning numbers in C/C++ > Advanced > Disable Specific Warnings.
Solution 4
Just to add to this, _CRT_NONSTDC_NO_DEPRECATE
worked for me in VS2019. _CRT_SECURE_NO_WARNINGS
alone did not clear this for me (I have both defined).
Similar to the other answers, this may be added by right-clicking the project in Solution Explorer, Then going to Properties->Configuration Properties->C/C++->Preprocessor->Preprocessor Definitions->Edit... then adding the line _CRT_NONSTDC_NO_DEPRECATE
.
Solution 5
Project ->project_name properties -> Configuration Properties -> C/C++ -> Preprocessor -> Preprocessor Definitions -> Edit... add line _CRT_SECURE_NO_WARNINGS
Nikolai
Updated on July 04, 2020Comments
-
Nikolai almost 4 years
In previous versions of Visual Studio using functions like _sleep or strncpy just outputs a warning. In the latest version, it's suddenly an error:
error C4996: '_sleep': This function or variable has been superseded by newer library or operating system functionality. Consider using Sleep instead. See online help for details.
I know I can disable it by adding
#pragma warning(disable: 4996)
in the beginning of the code, but it's extremely annoying that VS is trying to force me to use other functions. Is there any way to disable this behavior?Before you ask, "Treat Warnings As Errors" is disabled, and it errors even if I turn off all warnings!
-
Nathan Reed over 9 yearsDisabling SDL checks didn't fix the warning for some deprecated Windows API functions I ran into, like
GetVersionEx
. Had to disable warning 4996 specifically to fix those. -
Thomas Weller over 3 yearsThis was already mentioned in OP's question in 2013. Not sure how that qualified as an answer in 2018
-
RaHuL about 3 yearsWow thanks much for the guy who asked this question and the one who answers. It fixed the error for me