Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Incompatible implicit declaration of built-in function ‘malloc’

Tags:

c

malloc

struct

You likely forgot to #include <stdlib.h>


You need to #include <stdlib.h>. Otherwise it's defined as int malloc() which is incompatible with the built-in type void *malloc(size_t).


You're missing #include <stdlib.h>.


The stdlib.h file contains the header information or prototype of the malloc, calloc, realloc and free functions.

So to avoid this warning in ANSI C, you should include the stdlib header file.