Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Visual Studio 2013 error on C4996?

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:

unexpected 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!

like image 475
Nikolai Avatar asked Dec 07 '13 23:12

Nikolai


People also ask

How do you ignore warnings in C++?

To disable a set of warnings for a given piece of code, you have to start with a “push” pre-processor instruction, then with a disabling instruction for each of the warning you want to suppress, and finish with a “pop” pre-processor instruction.

Why is scanf deprecated?

It sounds like it's just a compiler warning. Usage of scanf_s prevents possible buffer overflow. So as suggested, you can try replacing scanf with scanf_s or disable the compiler warning.


2 Answers

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.

like image 55
Nikolai Avatar answered Oct 14 '22 00:10

Nikolai


enter at the beginning of the program:

#pragma warning(disable : 4996) 

and that's it.

like image 34
ניתאי דרעי Avatar answered Oct 13 '22 23:10

ניתאי דרעי