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!
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.
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.
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.
enter at the beginning of the program:
#pragma warning(disable : 4996)
and that's it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With