. Advertisement .
..3..
. Advertisement .
..4..
How to solve the problem – incompatible implicit declaration of built-in function ‘malloc’? I have the sample detail:
fileinfo_list* tempList = malloc(sizeof(fileinfo_list));
typedef struct {
fileinfo** filedata;
size_t nFiles;
size_t size;
size_t fileblock;
} fileinfo_list;
While I was running it, I found the warning message:
warning: incompatible implicit declaration of built-in function ‘malloc’
That is my question in my midterm exam, and it is urgent. I searched the solutions on some websites, but I didn’t get it. I may miss any line or other changes. I appreciate your assistance!
The cause: You get the error: incompatible implicit declaration of built-in function ‘malloc’ because it lack of
stdlib
header file. If not, it is written asint malloc()
, which is unsuited with the built-in formvoid *malloc(size t)
.Solution: It needs to
#include <stdlib.h>
to fix the problem.#include <stdlib.h>
is required. It must be#include <stdlib.h>
.