Declaración implícita incompatible de la función incorporada 'malloc'


Estoy recibiendo este error:

Advertencia: declaración implícita incompatible de la función incorporada 'malloc'

Estoy tratando de hacer esto:

fileinfo_list* tempList = malloc(sizeof(fileinfo_list));

Solo para la referencia, la estructura utilizada a mano es:

typedef struct {
    fileinfo** filedata;
    size_t nFiles;
    size_t size;
    size_t fileblock;
} fileinfo_list;

No veo nada malo en lo que he hecho. Solo estoy creando un tempList con el tamaño de 1 x fileinfo_list.

Author: Peter Mortensen, 2011-08-13

5 answers

Probablemente olvidaste incluir <stdlib.h>.

 289
Author: cnicutar,
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
2011-08-13 13:50:50

Necesitas #include <stdlib.h>. De lo contrario se define como int malloc() que es incompatible con el tipo incorporado void *malloc(size_t).

 39
Author: Omri Barel,
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-12-10 21:37:36

Estás perdido #include <stdlib.h>.

 14
Author: Antti,
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
2011-08-13 13:51:16

El stdlib.el archivo h contiene la información de cabecera o prototipo de las funciones malloc, calloc, realloc y free.

Así que para evitar esta advertencia en ANSI C, debe incluir el archivo de cabecera stdlib.

 3
Author: santosh sahu,
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-12-10 21:54:30

La única solución para tales advertencias es incluir stdlib.h en el programa.

 -4
Author: user3828152,
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-07-11 06:08:11