¿Por qué error Visual Studio 2013 en C4996?


En versiones anteriores de Visual Studio usando funciones como _sleep o strncpy solo genera una advertencia. En la última versión, de repente es un error:

error inesperado

Error C4996: '_sleep' : Esta función o variable ha sido reemplazada por la nueva biblioteca o funcionalidad del sistema operativo. Considere usar Duerme en su lugar. Consulte la ayuda en línea para obtener más detalles.

Sé que puedo desactivarlo agregando #pragma warning(disable: 4996) al principio del código, pero es extremadamente molesto que VS está tratando de obligarme a usar otras funciones. ¿Hay alguna manera de desactivar este comportamiento?

Antes de preguntar," Tratar las advertencias como errores " está desactivado, y se equivoca incluso si apago todas las advertencias!

Author: Stoogy, 2013-12-08

5 answers

Aparentemente los proyectos nuevos habilitan "SDK check" por defecto ahora, que trata estas advertencias como errores. Para deshabilitarlo, vaya a propiedades del proyecto - > Propiedades de configuración - > C / C++ - > General - > Comprobaciones de SDL - > No.

 68
Author: Nikolai,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-12-07 23:45:11

También puede deshabilitar números de advertencia específicos en C/C++ > Avanzado > Deshabilitar Advertencias específicas.

 4
Author: Peter Tseng,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-06-17 16:13:59

Introduzca al principio del programa:

#pragma warning(disable : 4996)

Y eso es todo.

 2
Author: ניתאי דרעי,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-02-27 19:16:27

Project ->project_name properties -> Configuration Properties -> C/C++ -> Preprocessor -> Preprocessor Definitions -> Edit... añadir línea _CRT_SECURE_NO_WARNINGS

 0
Author: Adam G.,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-01-05 20:55:20

Compilando todas las fuentes a las que me he referido:

Elimine las advertencias seguras (_CRT_SECURE_NO_WARNINGS) de los proyectos de forma predeterminada en Visual Studio

Respuesta de Kmcnamee sobre Cómo usar use _CRT_SECURE_NO_WARNINGS

Video que resolvió mi problema. https://www.youtube.com/watch?v=qWxGZLjwKL0

Aparentemente, el Ciclo de vida de Desarrollo de Seguridad (SDL) recomendó comprobaciones que incluyen habilitar funciones adicionales de generación de código seguro y funciones adicionales advertencias relevantes para la seguridad como errores.

Los pasos para resolver este problema son:

1. Go to Project-> "your project name" Properties
2. Under Configuration Properties, go to C/C++
3. Under C/C++, go to Preprocessor 
4. Select Preprocessor Definitions and click on Edit from the dropdown menu
5. In the blank space fill out _CRT_SECURE_NO_WARNINGS
 0
Author: xAditya3393,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-09-26 09:45:32